/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // ---------------------------------------------- // Name: XSCX121X786 // Description: X121 X786 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 IsX786HasLongSignal( const X121MarketConditions &conditions, // Specified Conditions int index = 0 // Array Index ) { // bool result = false; // bool long1 = // IsHKBullish(conditions) && IsSMHKBullish(conditions) && IsHullBullish(conditions, index) && IsSSLCBullish(conditions, index) && IsTrendBullish(conditions, index) && IsRibbonBullish(conditions, index) && IsBullishCandle(conditions.candles[1]) // ; // bool long2 = // IsTrendBullish(conditions) && IsNewPeakOverLast(conditions) && // ( // IsSCLowBullish(conditions) && ( // IsMCLowBullish(conditions) || IsLCLowBullish(conditions) || IsHCLowBullish(conditions) // ) // ) // ; // result = // long1 // || // long2 // ; // return result; } // // Shorts ... bool IsX786HasShortSignal( const X121MarketConditions &conditions, // Specified Conditions int index = 0 // Array Index ) { // bool result = false; // bool short1 = // IsHKBearish(conditions) && IsSMHKBearish(conditions) && IsHullBearish(conditions, index) && IsSSLCBearish(conditions, index) && IsTrendBearish(conditions, index) && IsRibbonBearish(conditions, index) && IsBearishCandle(conditions.candles[1]) // ; // bool short2 = // IsTrendBearish(conditions, index) && IsNewValeUnderLast(conditions) && // ( // IsSCHighBearish(conditions) && ( // IsMCHighBearish(conditions) || IsLCHighBearish(conditions) || IsHCHighBearish(conditions) // ) // ) // ; // result = // short1 // || // short2 // ; // return result; } // // CALCULATIONS ... // // Calculate Long Stop ... double CalculateX786LongStop(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 CalculateX786LongTarget(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 CalculateX786ShortStop(const X121MarketConditions &conditions) { // double result = 0; // return result; } // // Calculate Short Take Profits ... double CalculateX786ShortTarget(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 GenerateX786Signal( 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 ? IsX786HasLongSignal(conditions) : IsX786HasShortSignal(conditions) // ; // if (result) { // Add( ToString(X786), conditions.signal.providers); // double sl = // isLong ? CalculateX786LongStop(conditions) : CalculateX786ShortStop(conditions) // ; // double r2r = 3; // double tp = // isLong ? CalculateX786LongTarget(conditions, sl, entry, r2r) : CalculateX786ShortTarget(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 ... GenerateX786SignalSupports(conditions); } } // return result; } // // SUPPORTS ... // // Generate Required Support Signals and Attached Them into // Exists Signal of Conditions ... int GenerateX786SignalSupports( X121MarketConditions &conditions) { // int result = 0; // return result; } // // GUARDS ... // // Check Can Force Close All X786 Long Signals or not ... bool CanX786ForceCloseLongs(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 CanX786TrailLongsStop( 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 CanX786TrailShortsStop( 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; }