/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // ---------------------------------------------- // Name: XSCX121X92 // Description: X121 X92 Signal Provider ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://www.saherelm.ir" #property version "1.00" #property strict // #include "../Libraries/x-saherelm.x121.condition.parser.lib.mq5" // // CONDITIONS ... // // Longs ... bool IsX92HasLongSignal( const X121MarketConditions &conditions, // Specified Conditions int index = 0 // Array Index ) { // bool result = false; // bool long1 = // IsNewPeak(conditions) && IsValeSameAs(conditions) && IsNewPeakUnderLast(conditions) // ; // bool long2 = // IsSMHKBullish(conditions, index) && IsTrendBullish(conditions, index) && IsBullishCandle(conditions.candles[index + 1]) // && // (conditions.candles[index + 1].low > GetSMHKMax(conditions, index) || conditions.candles[index + 1].close > GetSMHKMax(conditions, index)) // && // conditions.xmanInfo.smhkHighs[index] == iSMHKHighest(conditions, index) // && // IsSCLowBullish(conditions, index) // ; // result = // long1 // || // long2 // ; // return result; } // // Shorts ... bool IsX92HasShortSignal( const X121MarketConditions &conditions, // Specified Conditions int index = 0 // Array Index ) { // bool result = false; // bool short1 = // IsNewVale(conditions) && IsPeakSameAs(conditions) && IsNewValeOverLast(conditions) // ; // bool short2 = // IsSMHKBearish(conditions, index) && IsTrendBearish(conditions, index) && IsBearishCandle(conditions.candles[index + 1]) // && // (conditions.candles[index + 1].high < GetSMHKMin(conditions, index) || conditions.candles[index + 1].open < GetSMHKMin(conditions, index)) // && // conditions.xmanInfo.smhkHighs[index] == iSMHKLowest(conditions, index) // && // IsSCHighBearish(conditions, index) // ; // result = // short1 // || // short2 // ; // return result; } // // CALCULATIONS ... // // Calculate Long Stop ... double CalculateX92LongStop(const X121MarketConditions &conditions) { // double result = 0; // double vale = conditions.xmanInfo.vales[0]; double med = (conditions.xmanInfo.sLLs[0] + conditions.xmanInfo.mLLs[0]) / 2; double fl1 = conditions.xmanInfo.fibLevel1s[0]; // result = // 0 // ; // return result; } // // Calculate Long Take Profits ... double CalculateX92LongTarget(const X121MarketConditions &conditions, double sl, double entry, double r2r = 1) { // double result = 0; // if (sl > 0 && entry > 0 && r2r > 0) { // double riskPrice = MathAbs(entry - sl); double rewardPrice = riskPrice * r2r; // result = entry + rewardPrice; } else { result = entry + PointToPrice(conditions.symbol, 60); } // return result; } // // Calculate Short Stop ... double CalculateX92ShortStop(const X121MarketConditions &conditions) { // double result = 0; // return result; } // // Calculate Short Take Profits ... double CalculateX92ShortTarget(const X121MarketConditions &conditions, double sl, double entry, double r2r = 1) { // double result = 0; // if (sl > 0 && entry > 0 && r2r > 0) { // double riskPrice = MathAbs(entry - sl); double rewardPrice = riskPrice * r2r; // result = entry - rewardPrice; } else { result = entry - PointToPrice(conditions.symbol, 60); } // return result; } // // SIGNALS ... // // Generate Signal ... bool GenerateX92Signal( X121MarketConditions &conditions, // Specified Conditions which Holds Signal also ... const XOHCLSupRes &supportAndResistances, // Specified Support and Resistances ... ENUM_POSITION_TYPE type, // Specified Which Signal Type must be Generated ... bool generateSupports = false // Specified Support Signals also Generated and Attached or not ... ) { // bool result = false; // bool isLong = IsLong(type); // // Retrieve Entry Price ... double entry = GetEntry( conditions.symbol, type); // result = // isLong ? IsX92HasLongSignal(conditions) : IsX92HasShortSignal(conditions) // ; // if (result) { // Add( ToString(X92), conditions.signal.providers); // double sl = // isLong ? CalculateX92LongStop(conditions) : CalculateX92ShortStop(conditions) // ; // double r2r = 3; // double tp = // isLong ? CalculateX92LongTarget(conditions, sl, entry, r2r) : CalculateX92ShortTarget(conditions, sl, entry, r2r) // ; // double volume = 0.01; // conditions.hasSignal = true; // conditions.signal.type = type; conditions.signal.symbol = conditions.symbol; conditions.signal.period = conditions.period; conditions.signal.supportResistances = supportAndResistances; // conditions.signal.sl = sl; conditions.signal.tp = tp; conditions.signal.r2r = r2r; conditions.signal.entry = entry; conditions.signal.volume = volume; conditions.signal.mode = X_ORDER_MODE_MARKET; // if (generateSupports) { // // Generate Required Support Signals ... GenerateX92SignalSupports(conditions); } } // return result; } // // SUPPORTS ... // // Generate Required Support Signals and Attached Them into // Exists Signal of Conditions ... int GenerateX92SignalSupports( X121MarketConditions &conditions) { // int result = 0; // return result; } // // GUARDS ... // // Check Can Force Close All X92 Long Signals or not ... bool CanX92ForceCloseLongs(const X121MarketConditions &conditions) { // bool result = false; // // 1- HK Min above FL 1 ... // 2- Trend Changed From Bullish To Bearish ... // double minHK = GetHKMin(conditions); bool isMinHKOverFL1 = minHK > conditions.xmanInfo.fibLevel1s[0]; bool isTrendSwitchedToBearish = IsTrendSwitchedToBearish(conditions); // result = // // isMinHKOverFL1 && isTrendSwitchedToBearish // ; // if (result) { // LogMessage("Test"); // } // return result; } // // Check for Trailing Long Positions Stops ... bool CanX92TrailLongsStop( const X121MarketConditions &conditions, double &newSL // ) { // bool result = false; // double prev = GetRibbonMin(conditions, 1); double current = GetRibbonMin(conditions); // result = current > prev; if (result) { newSL = current; } else { newSL = -1; } // return result; } // // Check For Trailing Short Positions Stops ... bool CanX92TrailShortsStop( const X121MarketConditions &conditions, double &newSL // ) { // bool result = false; // double prev = GetRibbonMax(conditions, 1); double current = GetRibbonMax(conditions); // result = current < prev; if (result) { newSL = current; } else { newSL = -1; } // return result; }