النتائج 1 إلى 11 من 11
  1. #1
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    03 ارجوا تعديل الاكسبيرت من mt4 الى mt5

    مرحبا
    ارجوا تعديل الاكسبيرت من mt4 الى mt5 وجزاكم الله كل خيرmulti.mq4

  2. #2
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    افتراضي

    Up UP UP UP

  3. #3
    الصورة الرمزية Algo_Master
    Algo_Master غير متواجد حالياً مشرف المتداول العربي
    تاريخ التسجيل
    Dec 2011
    الإقامة
    مصر
    المشاركات
    1,639

    افتراضي

    اقتباس المشاركة الأصلية كتبت بواسطة loveh999 مشاهدة المشاركة
    Up UP UP UP
    اهلا بك اخى

    تم الرد على الخاص
    توقيع العضو
    قسم البرمجه بمنتدى المتداول العربى
    يرحب بكم
    https://forum.arabictrader.com/f31.html

  4. #4
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    Thumbs up اهلا وسهلا بالمشرف العزيز

    اقتباس المشاركة الأصلية كتبت بواسطة Algo_Master مشاهدة المشاركة
    اهلا بك اخى

    تم الرد على الخاص
    معك يا طيب على الخاص

  5. #5
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    افتراضي

    للرفع مرة اخرى

  6. #6
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    09

    اقتباس المشاركة الأصلية كتبت بواسطة Algo_Master مشاهدة المشاركة
    اهلا بك اخى تم الرد على الخاص
    وين يا طيب لم اجد شيء في الخاص ولم اتلقى شيء يرجى التأكد ؟؟؟

  7. #7
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    افتراضي تم تعديل بعض الاكواد ولكن للأن لم يكتمل بعد

    تم تعديل بعض الاكواد ولكن للأن لم يكتمل بعد

    كود PHP:
    #property copyright "Sol.com"
    #property link      "http://www.Sol.com"


    //extern = input
    //TRUE = true
    //FALSE = false
    // init = OnInit
    //Point = _Point
    // Bid = (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID))
    // Ask = (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK))

    //////////////////////////not inside    TimeToStr = TimeToString

    // DoubleToStr = DoubleToString

    //////////////////////////not inside     CurTime = TimeCurrent

    //////////////////////////not inside     HistoryTotal = OrdersHistoryTotal

    //////////////////////////not inside     LocalTime TimeLocal

    // OP_BUY  = ORDER_TYPE_BUY
    // OP_SELL = ORDER_TYPE_SELL
    // OP_BUYLIMIT = ORDER_TYPE_BUY_LIMIT

    // OP_SELLLIMIT = ORDER_TYPE_SELL_LIMIT
    // OP_BUYSTOP = ORDER_TYPE_BUY_STOP

    // OP_SELLSTOP = ORDER_TYPE_SELL_STOP

    //Digits = _Digits

    /////?????? MarketInfo() = read SymbolInfoInteger/Double/String

    // ?? DayOfWeek() = TimeCurrent(tm);

    // StrToTime = StringToTime

    // OrderTicket = OrderGetTicket

    input bool TradeBuy true;
    input bool TradeSell true;
    input bool ResetSLAfterOppExe false;
    bool gi_88 false;
    input int Step1 150;
    input int TP1 150;
    int gi_100 0;
    input double Lots1 0.05;
    input int Step2 150;
    input int TP2 150;
    int gi_120 0;
    input double Lots2 0.05;
    input int Step3 150;
    input int TP3 150;
    int gi_140 0;
    input double Lots3 0.09;
    input int Step4 150;
    input int TP4 150;
    int gi_160 0;
    input double Lots4 0.13;
    input int Step5 150;
    input int TP5 150;
    int gi_180 0;
    input double Lots5 0.19;
    input int Step6 150;
    input int TP6 150;
    int gi_200 0;
    input double Lots6 0.25;
    input int Step7 150;
    input int TP7 150;
    int gi_220 0;
    input double Lots7 0.33;
    input int Step8 150;
    input int TP8 150;
    int gi_240 0;
    input double Lots8 0.40;
    input int Step9 150;
    input int TP9 150;
    int gi_260 0;
    input double Lots9 2.56;
    input int Step10 150;
    input int TP10 150;
    int gi_280 0;
    input double Lots10 5.12;
    int g_slippage_292 3;
    int gi_296 2;
    input int StartHour 0;
    input int EndHour 24;
    input int Magic 9999;
    int g_magic_312 5978278;
    input bool UseMACD false;
    input int BrokerMode 1;
    input bool MM_advisor false;
    input int FridayCloseTime 16;
    input int OpenOppositeStep 6;
    input bool UseTrailingOpposite true;
    input int TrailStart 40;
    input int TrailStep 15;
    int gi_348 30;
    input double LotsFactorOpposite 0;
    input int MaxSpread 120;
    //int gi_364 = D'31.12.2000 22:00';
    //int gi_368 = D'30.05.2010 22:00';
    //string gs_372 = "Version expired,contact Sol.com for updated version";
    bool gi_380 false;
    int gi_384;
    int gi_unused_388;
    int gi_392 5;
    bool g_global_var_396 false;
    bool g_global_var_400 false;

    int OnInit() {
       if (
    GlobalVariableCheck(Symbol() + "_InOpenOppositeModeSell")) g_global_var_396 GlobalVariableGet(Symbol() + "_InOpenOppositeModeSell");
       if (
    GlobalVariableCheck(Symbol() + "_InOpenOppositeModeBuy")) g_global_var_400 GlobalVariableGet(Symbol() + "_InOpenOppositeModeBuy");
       return (
    0);
    }

    int start() {
       
    int li_0;
       
    int li_4;
       
    int l_ticket_8;
       
    double l_price_12;
       
    double l_price_20;
       
    double l_price_28;
       
    double l_lots_36;
       
    double ld_44;
       
    double ld_52;
       
    bool l_bool_60;
       
    double ld_248;
       
    bool l_ticket_256;
       
    double l_price_260;
       
    bool li_272;
    // if (Check() == 0) return (0);
    // if (TimeCurrent() > StringToTime("2009.03.30")) {Alert("Time Expired!, Please Contact Sol.com!"); return (0);}
       
    ObjectCreate("CC"OBJ_LABEL000);
       
    ObjectSet("CC"OBJPROP_CORNER3);
       
    ObjectSet("CC"OBJPROP_XDISTANCE5);
       
    ObjectSet("CC"OBJPROP_YDISTANCE5);
       
    ObjectSet("CC"OBJPROP_BACKtrue);
       
    ObjectSetText("CC""Copyright © 2009, www.Sol.com"7"Arial"Silver);
       
    ObjectCreate("HB"OBJ_LABEL000);
       
    ObjectSet("HB"OBJPROP_CORNER3);
       
    ObjectSet("HB"OBJPROP_XDISTANCE5);
       
    ObjectSet("HB"OBJPROP_YDISTANCE15);
       
    ObjectSet("HB"OBJPROP_BACKtrue);
       
    ObjectSetText("HB""FxProPlus™ V2"9"Tahoma Bold"Tomato);
       if (!
    SpreadIsValid()) {
          Print(
    "Spread > MaxSpread");
          return (
    0);
       }
       
    gi_384 MarketInfo(Symbol(), MODE_STOPLEVEL);
       
    gi_unused_388 MarketInfo(Symbol(), MODE_SPREAD);
       if (
    gi_348 gi_384) {
          Print(
    "TPOpposite < stoplevel");
          return (
    0);
       }
       if (
    TrailStep gi_384) {
          Print(
    "TrailStep < stoplevel");
          return (
    0);
       }
       if (!
    g_global_var_396 && MyOrder(ORDER_TYPE_BUYg_magic_312) == 1) {
          
    g_global_var_396 true;
          
    GlobalVariableSet(Symbol() + "_InOpenOppositeModeSell"g_global_var_396);
       }
       if (!
    g_global_var_400 && MyOrder(ORDER_TYPE_SELLg_magic_312) == 1) {
          
    g_global_var_400 true;
          
    GlobalVariableSet(Symbol() + "_InOpenOppositeModeBuy"g_global_var_400);
       }
       if (
    g_global_var_396 && MyOrder(ORDER_TYPE_BUYg_magic_312) < 1) {
          while (
    MyOrder(ORDER_TYPE_SELLMagic) > 0DeleteAll(Magic1);
          
    g_global_var_396 false;
          
    GlobalVariableSet(Symbol() + "_InOpenOppositeModeSell"g_global_var_396);
       }
       if (
    g_global_var_400 && MyOrder(ORDER_TYPE_SELLg_magic_312) < 1) {
          while (
    MyOrder(ORDER_TYPE_BUYMagic) > 0DeleteAll(Magic0);
          
    g_global_var_400 false;
          
    GlobalVariableSet(Symbol() + "_InOpenOppositeModeBuy"g_global_var_400);
       }
       if (
    gi_380) return (0);
       
    int l_ticket_64 0;
       
    int l_ticket_68 0;
       
    int l_ticket_72 0;
       
    int l_ticket_76 0;
       
    double l_ord_lots_80 0;
       
    double l_ord_lots_88 0;
       
    double l_ord_open_price_96 0;
       
    double l_ord_open_price_104 0;
       
    double l_ord_takeprofit_112 0;
       
    double l_ord_takeprofit_120 0;
       
    double l_ord_lots_128 0;
       
    double l_ord_lots_136 0;
       
    double l_ord_lots_144 0;
       
    double l_ord_lots_152 0;
       
    string ls_160 "";
       
    string ls_168 "";
       
    string ls_176 "";
       
    string ls_184 "";
       
    string ls_192 "";
       
    string ls_200 "";
       
    string ls_208 "";
       
    string ls_216 "";
       
    string ls_224 "";
       if (
    MM_advisor == trueli_4 100;
       else 
    li_4 1;
       
    double ld_232 1.0;
       for (
    int li_240 1li_240 OpenOppositeStepli_240++) ld_232 2.0 ld_232;
       
    ld_232 FinalLots(ld_232);
       if (
    iMACD(NULL014269PRICE_CLOSE00) > iMACD(NULL014269PRICE_CLOSE01)) li_0 2;
       if (
    iMACD(NULL014269PRICE_CLOSE00) < iMACD(NULL014269PRICE_CLOSE01)) li_0 1;
       for (
    int l_pos_244 0l_pos_244 OrdersTotal(); l_pos_244++) {
          
    OrderSelect(l_pos_244SELECT_BY_POSMODE_TRADES);
          if (
    OrderSymbol() == Symbol() || BrokerMode == && OrderMagicNumber() == Magic) {
             if (
    OrderType() == ORDER_TYPE_BUY && l_ticket_64 OrderTicket()) {
                
    l_ord_lots_80 OrderLots();
                
    l_ord_open_price_96 OrderOpenPrice();
                
    l_ticket_64 OrderTicket();
                
    l_ord_takeprofit_120 OrderTakeProfit();
             }
             if (
    OrderType() == ORDER_TYPE_BUY)
                if (
    OrderLots() < l_ord_lots_144 || l_ord_lots_144 == 0.0l_ord_lots_144 OrderLots();
             if (
    OrderType() == ORDER_TYPE_SELL && l_ticket_68 OrderTicket()) {
                
    l_ord_lots_88 OrderLots();
                
    l_ord_open_price_104 OrderOpenPrice();
                
    l_ticket_68 OrderTicket();
                
    l_ord_takeprofit_112 OrderTakeProfit();
             }
             if (
    OrderType() == ORDER_TYPE_SELL)
                if (
    OrderLots() < l_ord_lots_152 || l_ord_lots_152 == 0.0l_ord_lots_152 OrderLots();
             if (
    OrderType() == ORDER_TYPE_BUY_LIMIT) {
                
    l_ticket_72 OrderTicket();
                
    l_ord_lots_128 OrderLots();
             }
             if (
    OrderType() == ORDER_TYPE_SELL_LIMIT) {
                
    l_ticket_76 OrderTicket();
                
    l_ord_lots_136 OrderLots();
             }
          }
       }
       if (
    l_ticket_64 == && l_ticket_72 != && !g_global_var_400) {
          
    OrderDelete(l_ticket_72);
          if (
    MyOrder(ORDER_TYPE_SELL_STOPg_magic_312) > 0DeleteOpposite(g_magic_312ORDER_TYPE_SELL_STOP);
       }
       if (
    l_ticket_64 == && l_ticket_72 == && TradeBuy) {
          if (!
    g_global_var_400 && MyOrder(ORDER_TYPE_SELL_STOPg_magic_312) > 0DeleteOpposite(g_magic_312ORDER_TYPE_SELL_STOP);
          if (
    TimeCurrent() >= gi_364 && TimeCurrent() <= gi_368) {
             
    l_price_20 = (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)) - gi_100 _Point;
             if (
    gi_100 <= 0l_price_20 0;
             
    l_price_28 = (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)) + TP1 _Point;
             if ((
    StartHour EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour EndHour && TimeHour(TimeCurrent()) >= StartHour ||
                
    TimeHour(TimeCurrent()) < EndHour)) {
                if (
    DayOfWeek() != gi_392 || Hour() < FridayCloseTime) {
                   if ((
    li_0 == && l_ticket_68 == 0) || UseMACD == false) {
                      if (!
    g_global_var_400 && MyOrder(ORDER_TYPE_SELL_STOPg_magic_312) < 1) {
                         if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_BUYLots1 li_4) >= 0.0) {
                            if (
    BrokerMode != && BrokerMode != 3OrderSend(Symbol(), ORDER_TYPE_BUYLots1, (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)), g_slippage_292l_price_20l_price_28"4 1Magic = " MagicMagic0CLR_NONE);
                            else {
                               
    l_ticket_8 OrderSend(Symbol(), ORDER_TYPE_BUYLots1, (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)), g_slippage_29200"4 2Magic = " MagicMagic0CLR_NONE);
                               
    l_bool_60 OrderModify(l_ticket_8OrderOpenPrice(), l_price_20l_price_280CLR_NONE);
                               if (
    l_bool_60 == false) Print("Error modifying BUY order : "GetLastError());
                            }
                         } else {
                            if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_BUYLots1) >= 0.0ls_224 "we recommend you to decrease your start lot or increase deposit";
                            else 
    ls_176 "BUY, " DoubleToString(Lots12) + " lots. ";
                         }
                      }
                   }
                }
             }
          } else 
    ls_168 gs_372;
       }
       if (
    l_ticket_68 == && l_ticket_76 != && !g_global_var_396) {
          
    OrderDelete(l_ticket_76);
          if (
    MyOrder(ORDER_TYPE_BUY_STOPg_magic_312) > 0DeleteOpposite(g_magic_312ORDER_TYPE_BUY_STOP);
       }
       if (
    l_ticket_68 == && l_ticket_76 == && TradeSell) {
          if (!
    g_global_var_396 && MyOrder(ORDER_TYPE_BUY_STOPg_magic_312) > 0DeleteOpposite(g_magic_312ORDER_TYPE_BUY_STOP);
          if (
    TimeCurrent() >= gi_364 && TimeCurrent() <= gi_368) {
             
    l_price_20 = (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)) + gi_100 _Point;
             if (
    gi_100 <= 0l_price_20 0;
             
    l_price_28 = (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)) - TP1 _Point;
             if ((
    StartHour EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour EndHour && TimeHour(TimeCurrent()) >= StartHour ||
                
    TimeHour(TimeCurrent()) < EndHour)) {
                if (
    DayOfWeek() != gi_392 || Hour() < FridayCloseTime) {
                   if ((
    li_0 == && l_ticket_64 == 0) || UseMACD == false) {
                      if (!
    g_global_var_396 && MyOrder(ORDER_TYPE_BUY_STOPg_magic_312) < 1) {
                         if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_SELLLots1 li_4) >= 0.0) {
                            if (
    BrokerMode != && BrokerMode != 3OrderSend(Symbol(), ORDER_TYPE_SELLLots1, (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)), g_slippage_292l_price_20l_price_28"3 1Magic = " MagicMagic0CLR_NONE);
                            else {
                               
    l_ticket_8 OrderSend(Symbol(), ORDER_TYPE_SELLLots1, (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)), g_slippage_29200"3 2Magic = " MagicMagic0CLR_NONE);
                               
    l_bool_60 OrderModify(l_ticket_8OrderOpenPrice(), l_price_20l_price_280CLR_NONE);
                               if (
    l_bool_60 == false) Print("Error modifying SELL order : "GetLastError());
                            }
                         } else {
                            if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_SELLLots1) >= 0.0ls_224 "we recommend you to decrease your start lot or increase deposit";
                            else 
    ls_184 "SELL, " DoubleToString(Lots12) + " lots. ";
                         }
                      }
                   }
                }
             }
          } else 
    ls_168 gs_372;
       }
       if (
    l_ticket_64 != && l_ticket_72 != 0) {
          if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_BUYl_ord_lots_128) < 0.0) {
             
    ls_208 "BUYLIMIT, " DoubleToString(l_ord_lots_1282) + " lots. ";
             
    OrderDelete(l_ticket_72);
          }
       }
       if (
    l_ticket_64 != && l_ticket_72 == 0) {
          if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_BUYNextLots(l_ord_lots_80)) >= 0.0) {
             
    ld_52 FinalStepByLots(l_ord_lots_80);
             
    ld_44 FinalTPByLots(NextLots(l_ord_lots_80));
             
    ld_248 FinalSLByLots(NextLots(l_ord_lots_80));
             
    l_price_12 l_ord_open_price_96 ld_52 _Point;
             
    l_price_20 l_price_12 ld_248 _Point;
             if (
    ld_248 <= 0.0l_price_20 0;
             
    l_price_28 l_price_12 ld_44 _Point;
             
    l_lots_36 NormalizeDouble(NextLots(l_ord_lots_80), gi_296);
             if (
    NextLots(l_ord_lots_80) < ld_232 && !g_global_var_400 && MyOrder(ORDER_TYPE_SELL_STOPg_magic_312) < 1OrderSend(Symbol(), ORDER_TYPE_BUY_LIMITl_lots_36l_price_12g_slippage_292l_price_20l_price_28"2 Magic = " MagicMagic0CLR_NONE);
             else {
                if (
    NextLots(l_ord_lots_80) >= ld_232 && !g_global_var_400 && MyOrder(ORDER_TYPE_SELL_STOPg_magic_312) < 1) {
                   Print(
    "trying open sell stop");
                   if (
    l_price_12 > (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)) - gi_384 _Pointl_price_12 = (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)) - gi_384 _Point;
                   
    l_ticket_256 false;
                   
    l_price_260 l_price_12 MarketInfo(Symbol(), MODE_SPREAD) * _Point;
                   if (!
    UseTrailingOpposite) {
                      
    l_ticket_256 OrderSend(Symbol(), ORDER_TYPE_SELL_STOPl_lots_36 LotsFactorOppositel_price_260g_slippage_292l_price_28 MarketInfo(Symbol(), MODE_SPREAD) * _Pointl_price_260 gi_348 _Point"2 Magic = " +
                         
    g_magic_312g_magic_3120CLR_NONE);
                   } else {
                      
    l_ticket_256 OrderSend(Symbol(), ORDER_TYPE_SELL_STOPl_lots_36 LotsFactorOppositel_price_260g_slippage_292l_price_28 MarketInfo(Symbol(), MODE_SPREAD) * _Point0.0"2 Magic = " +
                         
    g_magic_312g_magic_3120CLR_NONE);
                   }
                   if (
    l_ticket_256OrderSend(Symbol(), ORDER_TYPE_BUY_LIMITl_lots_36l_price_12g_slippage_292l_price_20l_price_28"2 Magic = " MagicMagic0CLR_NONE);
                }
             }
          } else 
    ls_192 "BUYLIMIT, " DoubleToString(NextLots(l_ord_lots_80), 2) + " lots. ";
       }
       if (
    l_ticket_68 != && l_ticket_76 != 0) {
          if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_SELLl_ord_lots_136) < 0.0) {
             
    ls_216 "SELLLIMIT, " DoubleToString(l_ord_lots_1362) + " lots. ";
             
    OrderDelete(l_ticket_76);
          }
       }
       if (
    l_ticket_68 != && l_ticket_76 == 0) {
          if (
    AccountFreeMarginCheck(Symbol(), ORDER_TYPE_SELLNextLots(l_ord_lots_88)) >= 0.0) {
             
    ld_52 FinalStepByLots(l_ord_lots_88);
             
    ld_44 FinalTPByLots(NextLots(l_ord_lots_88));
             
    ld_248 FinalSLByLots(NextLots(l_ord_lots_88));
             
    l_price_12 l_ord_open_price_104 ld_52 _Point;
             
    l_price_20 l_price_12 ld_248 _Point;
             if (
    ld_248 <= 0.0l_price_20 0;
             
    l_price_28 l_price_12 ld_44 _Point;
             
    l_lots_36 NormalizeDouble(NextLots(l_ord_lots_88), gi_296);
             if (
    NextLots(l_ord_lots_88) < ld_232 && !g_global_var_396 && MyOrder(ORDER_TYPE_BUY_STOPg_magic_312) < 1OrderSend(Symbol(), ORDER_TYPE_SELL_LIMITl_lots_36l_price_12g_slippage_292l_price_20l_price_28"1 Magic = " MagicMagic0CLR_NONE);
             else {
                if (
    NextLots(l_ord_lots_88) >= ld_232 && !g_global_var_396 && MyOrder(ORDER_TYPE_BUY_STOPg_magic_312) < 1) {
                   Print(
    "trying open buy stop");
                   if (
    l_price_12 < (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)) + gi_384 _Pointl_price_12 = (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)) + gi_384 _Point;
                   
    l_ticket_256 false;
                   
    l_price_260 l_price_12 MarketInfo(Symbol(), MODE_SPREAD) * _Point;
                   if (!
    UseTrailingOpposite) {
                      
    l_ticket_256 OrderSend(Symbol(), ORDER_TYPE_BUY_STOPl_lots_36 LotsFactorOppositel_price_260g_slippage_292l_price_28 MarketInfo(Symbol(), MODE_SPREAD) * _Pointl_price_260 +
                         
    gi_348 _Point"1 Magic = " g_magic_312g_magic_3120CLR_NONE);
                   } else {
                      
    l_ticket_256 OrderSend(Symbol(), ORDER_TYPE_BUY_STOPl_lots_36 LotsFactorOppositel_price_260g_slippage_292l_price_28 MarketInfo(Symbol(), MODE_SPREAD) * _Point0.0"1 Magic = " +
                         
    g_magic_312g_magic_3120CLR_NONE);
                   }
                   if (
    l_ticket_256OrderSend(Symbol(), ORDER_TYPE_SELL_LIMITl_lots_36l_price_12g_slippage_292l_price_20l_price_28"1 Magic = " MagicMagic0CLR_NONE);
                }
             }
          } else 
    ls_200 "SELLLIMIT, " DoubleToString(NextLots(l_ord_lots_88), 2) + " lots. ";
       }
       for (
    l_pos_244 0l_pos_244 OrdersTotal(); l_pos_244++) {
          
    OrderSelect(l_pos_244SELECT_BY_POSMODE_TRADES);
          if (
    OrderSymbol() == Symbol() || BrokerMode == && OrderType() == ORDER_TYPE_BUY && l_ticket_64 != && OrderMagicNumber() == Magic) {
             if (
    l_ticket_64 OrderTicket()) l_price_28 l_ord_takeprofit_120;
             else 
    l_price_28 OrderTakeProfit();
             if (
    NormalizeDouble(l_price_28 OrderTakeProfit(), _Digits) != 0.0OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_280CLR_NONE);
          }
          if (
    OrderSymbol() == Symbol() || BrokerMode == && OrderType() == ORDER_TYPE_SELL && l_ticket_68 != && OrderMagicNumber() == Magic) {
             if (
    l_ticket_68 OrderTicket()) l_price_28 l_ord_takeprofit_112;
             else 
    l_price_28 OrderTakeProfit();
             if (
    NormalizeDouble(l_price_28 OrderTakeProfit(), _Digits) != 0.0OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_280CLR_NONE);
          }
       }
       if (
    ls_176 != "" || ls_184 != "" || ls_192 != "" || ls_200 != "" || ls_208 != "" || ls_216 != ""ls_160 "Not enough margin for opening orders: ";
       
    Comment(ls_168
          
    "\n"ls_160ls_176ls_184ls_192ls_200ls_208ls_216
       
    "\n"ls_224);
       if (
    g_global_var_396 && MyOrder(ORDER_TYPE_BUYg_magic_312) > && MyOrder(ORDER_TYPE_SELLMagic) > 0) {
          for (
    int l_pos_268 0l_pos_268 OrdersTotal(); l_pos_268++) {
             
    OrderSelect(l_pos_268SELECT_BY_POS);
             if ((
    OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_312 && OrderType() == ORDER_TYPE_BUY)) {
                
    OrderSelect(l_pos_268SELECT_BY_POS);
                
    SetSLWhenOppositeExe(MagicORDER_TYPE_SELLOrderOpenPrice());
                break;
             }
          }
          for (
    l_pos_268 0l_pos_268 OrdersTotal(); l_pos_268++) {
             
    OrderSelect(l_pos_268SELECT_BY_POS);
             if ((
    OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == ORDER_TYPE_SELL)) {
                
    OrderSelect(l_pos_268SELECT_BY_POS);
                
    SetTPWhenOppositeExe(g_magic_312ORDER_TYPE_BUYOrderTakeProfit());
                break;
             }
          }
       }
       if (
    g_global_var_400 && MyOrder(ORDER_TYPE_SELLg_magic_312) > && MyOrder(ORDER_TYPE_BUYMagic) > 0) {
          for (
    l_pos_268 0l_pos_268 OrdersTotal(); l_pos_268++) {
             
    OrderSelect(l_pos_268SELECT_BY_POS);
             if ((
    OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_312 && OrderType() == ORDER_TYPE_SELL)) {
                
    OrderSelect(l_pos_268SELECT_BY_POS);
                
    SetSLWhenOppositeExe(MagicORDER_TYPE_BUYOrderOpenPrice());
                break;
             }
          }
          for (
    l_pos_268 0l_pos_268 OrdersTotal(); l_pos_268++) {
             
    OrderSelect(l_pos_268SELECT_BY_POS);
             if ((
    OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == ORDER_TYPE_BUY)) {
                
    OrderSelect(l_pos_268SELECT_BY_POS);
                
    SetTPWhenOppositeExe(g_magic_312ORDER_TYPE_SELLOrderTakeProfit());
                break;
             }
          }
       }
       if (
    UseTrailingOpposite) {
          if (
    g_global_var_396 && MyOrder(ORDER_TYPE_BUYg_magic_312) > 0) {
             
    li_272 TrailOrder(g_magic_312ORDER_TYPE_BUY);
             if (
    li_272DeleteAll(Magic1);
          }
          if (
    g_global_var_400 && MyOrder(ORDER_TYPE_SELLg_magic_312) > 0) {
             
    li_272 TrailOrder(g_magic_312ORDER_TYPE_SELL);
             if (
    li_272DeleteAll(Magic0);
          }
       }
       return (
    0);
    }

    int FinalStepByLots(double ad_0) {
       if (
    ad_0 0.0 && ad_0 Lots2) return (Step1);
       else {
          if (
    ad_0 Lots1 && ad_0 Lots3) return (Step2);
          else {
             if (
    ad_0 Lots2 && ad_0 Lots4) return (Step3);
             else {
                if (
    ad_0 Lots3 && ad_0 Lots5) return (Step4);
                else {
                   if (
    ad_0 Lots4 && ad_0 Lots6) return (Step5);
                   else {
                      if (
    ad_0 Lots5 && ad_0 Lots7) return (Step6);
                      else {
                         if (
    ad_0 Lots6 && ad_0 Lots8) return (Step7);
                         else {
                            if (
    ad_0 Lots7 && ad_0 Lots9) return (Step8);
                            else {
                               if (
    ad_0 Lots8 && ad_0 Lots10) return (Step9);
                               else
                                  if (
    ad_0 Lots9) return (Step10);
                            }
                         }
                      }
                   }
                }
             }
          }
       }
       return (
    Step10);
    }

    int FinalTPByLots(double ad_0) {
       if (
    ad_0 0.0 && ad_0 Lots2) return (TP1);
       else {
          if (
    ad_0 Lots1 && ad_0 Lots3) return (TP2);
          else {
             if (
    ad_0 Lots2 && ad_0 Lots4) return (TP3);
             else {
                if (
    ad_0 Lots3 && ad_0 Lots5) return (TP4);
                else {
                   if (
    ad_0 Lots4 && ad_0 Lots6) return (TP5);
                   else {
                      if (
    ad_0 Lots5 && ad_0 Lots7) return (TP6);
                      else {
                         if (
    ad_0 Lots6 && ad_0 Lots8) return (TP7);
                         else {
                            if (
    ad_0 Lots7 && ad_0 Lots9) return (TP8);
                            else {
                               if (
    ad_0 Lots8 && ad_0 Lots10) return (TP9);
                               else
                                  if (
    ad_0 Lots9) return (TP10);
                            }
                         }
                      }
                   }
                }
             }
          }
       }
       return (
    TP10);
    }

    int FinalSLByLots(double ad_0) {
       if (
    ad_0 0.0 && ad_0 Lots2) return (gi_100);
       else {
          if (
    ad_0 Lots1 && ad_0 Lots3) return (gi_120);
          else {
             if (
    ad_0 Lots2 && ad_0 Lots4) return (gi_140);
             else {
                if (
    ad_0 Lots3 && ad_0 Lots5) return (gi_160);
                else {
                   if (
    ad_0 Lots4 && ad_0 Lots6) return (gi_180);
                   else {
                      if (
    ad_0 Lots5 && ad_0 Lots7) return (gi_200);
                      else {
                         if (
    ad_0 Lots6 && ad_0 Lots8) return (gi_220);
                         else {
                            if (
    ad_0 Lots7 && ad_0 Lots9) return (gi_240);
                            else {
                               if (
    ad_0 Lots8 && ad_0 Lots10) return (gi_260);
                               else
                                  if (
    ad_0 Lots9) return (gi_280);
                            }
                         }
                      }
                   }
                }
             }
          }
       }
       return (
    gi_280);
    }

    double FinalLots(double ad_0) {
       switch (
    ad_0) {
       case 
    1.0:
          return (
    Lots1);
       case 
    2.0:
          return (
    Lots2);
       case 
    4.0:
          return (
    Lots3);
       case 
    8.0:
          return (
    Lots4);
       case 
    16.0:
          return (
    Lots5);
       case 
    32.0:
          return (
    Lots6);
       case 
    64.0:
          return (
    Lots7);
       case 
    128.0:
          return (
    Lots8);
       case 
    256.0:
          return (
    Lots9);
       case 
    512.0:
          return (
    Lots10);
       }
       return (
    TP10);
    }

    double NextLots(double ad_0) {
       if (
    NormalizeDouble(ad_0 Lots1gi_296) == 0.0) return (Lots2);
       else {
          if (
    NormalizeDouble(ad_0 Lots2gi_296) == 0.0) return (Lots3);
          else {
             if (
    NormalizeDouble(ad_0 Lots3gi_296) == 0.0) return (Lots4);
             else {
                if (
    NormalizeDouble(ad_0 Lots4gi_296) == 0.0) return (Lots5);
                else {
                   if (
    NormalizeDouble(ad_0 Lots5gi_296) == 0.0) return (Lots6);
                   else {
                      if (
    NormalizeDouble(ad_0 Lots6gi_296) == 0.0) return (Lots7);
                      else {
                         if (
    NormalizeDouble(ad_0 Lots7gi_296) == 0.0) return (Lots8);
                         else {
                            if (
    NormalizeDouble(ad_0 Lots8gi_296) == 0.0) return (Lots9);
                            else
                               if (
    NormalizeDouble(ad_0 Lots9gi_296) == 0.0) return (Lots10);
                         }
                      }
                   }
                }
             }
          }
       }
       return (
    Lots10);
    }

    int MyOrder(int a_cmd_0int a_magic_4) {
       
    int l_pos_8 0;
       
    int l_count_12 0;
       while (
    l_pos_8 OrdersTotal()) {
          if (
    OrderSelect(l_pos_8SELECT_BY_POSMODE_TRADES))
             if (
    OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_4 && OrderType() == a_cmd_0l_count_12++;
          
    l_pos_8++;
       }
       return (
    l_count_12);
    }

    void DeleteAll(int a_magic_0int ai_4) {
       
    int l_count_12;
       
    bool li_16;
       for (
    int l_pos_8 0l_pos_8 OrdersTotal(); l_pos_8++) {
          
    OrderSelect(l_pos_8SELECT_BY_POSMODE_TRADES);
          if (
    OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0) {
             if (
    IsTradeContextBusy()) {
                Print(
    "Trade context is busy! The expert cannot close Pending Order!");
                return;
             }
             
    RefreshRates();
             
    l_count_12 0;
             
    li_16 false;
             while (
    l_count_12 10 && !li_16) {
                if (
    ai_4 == && OrderType() == ORDER_TYPE_BUYli_16 OrderClose(OrderTicket(), OrderLots(), (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)), g_slippage_292);
                else {
                   if (
    ai_4 == && OrderType() == ORDER_TYPE_SELLli_16 OrderClose(OrderTicket(), OrderLots(), (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)), g_slippage_292);
                   else
                      if ((
    ai_4 == && OrderType() == ORDER_TYPE_BUY_LIMIT) || (ai_4 == && OrderType() == ORDER_TYPE_SELL_LIMIT)) li_16 OrderDelete(OrderTicket(), CLR_NONE);
                }
                
    RefreshRates();
                if (
    l_count_12 == 10) {
                   Print(
    "10 attempts to close Orders have failed");
                   break;
                }
                
    l_count_12++;
             }
          }
       }
    }

    void DeleteOpposite(int a_magic_0int a_cmd_4) {
       for (
    int l_pos_8 0l_pos_8 OrdersTotal(); l_pos_8++) {
          
    OrderSelect(l_pos_8SELECT_BY_POS);
          if (
    OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0 && OrderType() == a_cmd_4OrderDelete(OrderTicket());
       }
    }

    /*
    int Check() 
      {if (IsDemo() == true) return (1);
       if (IsTesting() == true) return (1);
       Alert("Demo accounts only- Contact Sol.com to purchase");
       return (0);}
    */
    /*     bool IsDemo(){
       ENUM_ACCOUNT_TRADE_MODE tradeMode=(ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE);
       if(tradeMode == ACCOUNT_TRADE_MODE_DEMO) return(true);
       // tradeMode is ACCOUNT_TRADE_MODE_CONTEST or ACCOUNT_TRADE_MODE_REAL
       return(false);
    }*/

    int TrailOrder(int a_magic_0int a_cmd_4) {
       
    double l_price_12;
       if (
    TrailStep 0) {
          for (
    int l_pos_8 0l_pos_8 OrdersTotal(); l_pos_8++) {
             if (
    OrderSelect(l_pos_8SELECT_BY_POSMODE_TRADES) && OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol()) {
                if (
    OrderType() == ORDER_TYPE_BUY && OrderType() == a_cmd_4) {
                   
    RefreshRates();
                   
    l_price_12 NormalizeDouble((::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)) - _Point TrailStep_Digits);
                   if (!(
    l_price_12 OrderStopLoss() && (::SymbolInfoDouble(_Symbol, ::SYMBOL_BID)) - _Point TrailStart OrderOpenPrice())) continue;
                   if (!(
    OrderModify(OrderTicket(), OrderOpenPrice(), l_price_12OrderTakeProfit(), -1))) continue;
                   return (
    1);
                }
                if (
    OrderType() == ORDER_TYPE_SELL && OrderType() == a_cmd_4) {
                   
    RefreshRates();
                   
    l_price_12 NormalizeDouble((::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)) + _Point TrailStep_Digits);
                   if (
    l_price_12 OrderStopLoss() && (::SymbolInfoDouble(_Symbol, ::SYMBOL_ASK)) + _Point TrailStart OrderOpenPrice())
                      if (
    OrderModify(OrderTicket(), OrderOpenPrice(), l_price_12OrderTakeProfit(), -1)) return (1);
                }
             }
          }
       }
       return (
    0);
    }

    void SetSLWhenOppositeExe(int a_magic_0int a_cmd_4double ad_8) {
       
    double l_price_20;
       
    double l_ord_takeprofit_28;
       if (
    TrailStep 0) {
          for (
    int l_pos_16 0l_pos_16 OrdersTotal(); l_pos_16++) {
             
    OrderSelect(l_pos_16SELECT_BY_POS);
             if ((
    OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0 && OrderType() == a_cmd_4)) {
                if (
    a_cmd_4 == ORDER_TYPE_BUY) {
                   
    l_price_20 ad_8 TrailStart _Point MarketInfo(Symbol(), MODE_SPREAD) * _Point;
                   
    l_ord_takeprofit_28 OrderTakeProfit();
                   if (
    ResetSLAfterOppExel_price_20 0.0;
                   if (
    gi_88l_ord_takeprofit_28 0.0;
                   if (
    NormalizeDouble(l_price_20 OrderStopLoss(), _Digits) != 0.0OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20l_ord_takeprofit_280);
                } else {
                   if (
    a_cmd_4 == ORDER_TYPE_SELL) {
                      
    l_price_20 ad_8 TrailStart _Point MarketInfo(Symbol(), MODE_SPREAD) * _Point;
                      
    l_ord_takeprofit_28 OrderTakeProfit();
                      if (
    ResetSLAfterOppExel_price_20 0.0;
                      if (
    gi_88l_ord_takeprofit_28 0.0;
                      if (
    NormalizeDouble(l_price_20 OrderStopLoss(), _Digits) != 0.0OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20l_ord_takeprofit_280);
                   }
                }
             }
          }
       }
    }

    void SetTPWhenOppositeExe(int a_magic_0int a_cmd_4double ad_8) {
       
    double l_price_20;
       for (
    int l_pos_16 0l_pos_16 OrdersTotal(); l_pos_16++) {
          
    OrderSelect(l_pos_16SELECT_BY_POS);
          if ((
    OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0 && OrderType() == a_cmd_4)) {
             if (
    a_cmd_4 == ORDER_TYPE_BUY) {
                
    l_price_20 ad_8 MarketInfo(Symbol(), MODE_SPREAD) * _Point;
                if (
    NormalizeDouble(l_price_20 OrderStopLoss(), _Digits) != 0.0OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20OrderTakeProfit(), 0);
             } else {
                if (
    a_cmd_4 == ORDER_TYPE_SELL) {
                   
    l_price_20 ad_8 MarketInfo(Symbol(), MODE_SPREAD) * _Point;
                   if (
    NormalizeDouble(l_price_20 OrderStopLoss(), _Digits) != 0.0OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20OrderTakeProfit(), 0);
                }
             }
          }
       }
    }

    bool SpreadIsValid() {
       if (
    MarketInfo(Symbol(), MODE_SPREAD) > MaxSpread) return (false);
       return (
    true);


  8. #8
    الصورة الرمزية loveh999
    loveh999 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jul 2007
    الإقامة
    فلسطين
    المشاركات
    742

    05

    الحمد لله تم تعديل الاكسبيرت عن طريق شات جي تي بي ولكن يوجد خطأ واحد فقط فهل من مساعد

    كود PHP:
    #property copyright "Copyright © 2009, Trader12."
    #property link      "Trader12"

    #include <Trade\Trade.mqh>
    CTrade trade;

    input string  Info      "If Your Broker Allwed Hedge";
    input string  Info_1    "You Cant Choose BUY & SELL In one Chart";
    input string  Info_2    "You Must Open Two Chart If Use BUY & SELL In One Time";
    input string  Info_3    "You Must Change Magic Number If Use BUY & SELL & Pair";

    input bool    Tradebuy  true;
    input bool    Tradesell true;

    input double  AmountmoneyLose 10;
    input int     magic           9999;
    int           gi_80           5000;   // stays normal variable, not input
    input int     slipp           3;
    input int     Dalta           5;

    input string  Set_MA_1  "Moving Average 1";
    input int     Period1   13;
    input int     MA_SHIFT1 0;
    input int     MA_METHOD11;

    input string  Set_MA_2  "Moving Average 2";
    input int     Period2   21;
    input int     MA_SHIFT2 0;
    input int     MA_METHOD21;

    input string  Set_Double "You Can Choose Lot & Step & Target Profit For 40 Double";

    input double Lot1 0.01;
    input int    step1 200;
    input int    TP1 200;

    input double Lot2 0.01;
    input int    step2 200;
    input int    TP2 200;

    input double Lot3 0.02;
    input int    step3 200;
    input int    TP3 200;

    input double Lot4 0.04;
    input int    step4 200;
    input int    TP4 200;

    input double Lot5 0.08;
    input int    step5 200;
    input int    TP5 200;

    input double Lot6 0.16;
    input int    step6 200;
    input int    TP6 200;

    input double Lot7 0.30;
    input int    step7 200;
    input int    TP7 200;

    input double Lot8 0.60;
    input int    step8 200;
    input int    TP8 200;

    input double Lot9 0.68;
    input int    step9 200;
    input int    TP9 200;

    input double Lot10 0.76;
    input int    step10 20;
    input int    TP10 30;

    input double Lot11 0.84;
    input int    step11 20;
    input int    TP11 35;

    input double Lot12 0.92;
    input int    step12 20;
    input int    TP12 40;

    input double Lot13 1.00;
    input int    step13 20;
    input int    TP13 45;

    input double Lot14 1.08;
    input int    step14 20;
    input int    TP14 50;

    input double Lot15 1.14;
    input int    step15 20;
    input int    TP15 55;

    input double Lot16 1.22;
    input int    step16 20;
    input int    TP16 60;

    input double Lot17 1.30;
    input int    step17 20;
    input int    TP17 65;

    input double Lot18 1.38;
    input int    step18 20;
    input int    TP18 70;

    input double Lot19 1.46;
    input int    step19 20;
    input int    TP19 75;

    input double Lot20 1.54;
    input int    step20 20;
    input int    TP20 80;

    input double Lot21 6.8;
    input int    step21 500;
    input int    TP21 40;

    input double Lot22 6.8;
    input int    step22 30;
    input int    TP22 40;

    input double Lot23 6.8;
    input int    step23 30;
    input int    TP23 40;

    input double Lot24 6.8;
    input int    step24 30;
    input int    TP24 40;

    input double Lot25 6.8;
    input int    step25 30;
    input int    TP25 40;

    input double Lot26 6.8;
    input int    step26 30;
    input int    TP26 40;

    input double Lot27 6.8;
    input int    step27 30;
    input int    TP27 40;

    input double Lot28 6.8;
    input int    step28 30;
    input int    TP28 40;

    input double Lot29 6.8;
    input int    step29 30;
    input int    TP29 40;

    input double Lot30 6.8;
    input int    step30 30;
    input int    TP30 40;

    input double Lot31 6.8;
    input int    step31 30;
    input int    TP31 40;

    input double Lot32 6.8;
    input int    step32 30;
    input int    TP32 40;

    input double Lot33 6.8;
    input int    step33 30;
    input int    TP33 40;

    input double Lot34 6.8;
    input int    step34 30;
    input int    TP34 40;

    input double Lot35 6.8;
    input int    step35 30;
    input int    TP35 40;

    input double Lot36 6.8;
    input int    step36 30;
    input int    TP36 40;

    input double Lot37 6.8;
    input int    step37 30;
    input int    TP37 40;

    input double Lot38 6.8;
    input int    step38 30;
    input int    TP38 40;

    input double Lot39 6.8;
    input int    step39 30;
    input int    TP39 40;

    input double Lot40 6.8;
    input int    step40 30;
    input int    TP40 40;


    double g_price_812;
    double g_price_828;
    double g_price_836;
    double g_price_844;
    double g_price_852;
    int g_ticket_860 0;
    int g_ticket_864 0;
    int gi_unused_868 0;
    int gi_unused_872 0;
    int g_ticket_876 0;
    int g_ticket_880 0;
    double g_ord_takeprofit_884 0.0;
    double g_ord_takeprofit_892 0.0;
    double g_ord_lots_900 0.0;
    double g_ord_lots_908 0.0;
    double g_ord_lots_916 0.0;
    double g_ord_open_price_924 0.0;
    double g_ord_open_price_932 0.0;
    double gd_940 0.0;
    double gd_948 0.0;
    double gd_unused_956 0.0;
    int gi_972 16711680;
    int gi_1036 10;

    void objectCreate(
       
    string name,
       
    int x,
       
    int y,
       
    string text "-",
       
    int fontsize 40,
       
    string fontname "Arial",
       
    color col clrWhite,
       
    int corner CORNER_LEFT_UPPER
    )
    {
    long chart_id ChartID();
    int  window   0// main window in EA

    // For indicators, you can keep:
     // int window = WindowOnDropped();

       // Delete old object if exists (avoid "already exists" errors)
       
    if(ObjectFind(chart_idname) >= 0)
          
    ObjectDelete(chart_idname);

       
    // Create label
       
    if(!ObjectCreate(chart_idnameOBJ_LABELwindow00))
       {
          Print(
    "❌ Failed to create label: "name);
          return;
       }

       
    // Set label properties
       
    ObjectSetInteger(chart_idnameOBJPROP_CORNERcorner);
       
    ObjectSetInteger(chart_idnameOBJPROP_XDISTANCEx);
       
    ObjectSetInteger(chart_idnameOBJPROP_YDISTANCEy);
       
    ObjectSetInteger(chart_idnameOBJPROP_COLORcol);
       
    ObjectSetInteger(chart_idnameOBJPROP_FONTSIZEfontsize);
       
    ObjectSetString(chart_idnameOBJPROP_FONTfontname);
       
    ObjectSetString(chart_idnameOBJPROP_TEXTtext);
    }
    //+------------------------------------------------------------------+
    //| Expert initialization function                                   |
    //+------------------------------------------------------------------+
    int OnInit()
    {
       
    gd_unused_956 Lot1;
       return(
    INIT_SUCCEEDED);
    }

    //+------------------------------------------------------------------+
    //| Expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
       
    ObjectDelete(ChartID(), "Info");
       
    ObjectDelete(ChartID(), "Info1");
       
    ObjectDelete(ChartID(), "Mode");
       
    ObjectDelete(ChartID(), "Risk");
       
    Comment("");
    }

    //+------------------------------------------------------------------+
    //| Expert tick function                                             |
    //+------------------------------------------------------------------+
    void OnTick()
    {
       
    // Account information
       
    Comment(
          
    "\n SolMoon",
          
    "\n H$H ",
          
    "\n------------------------------------------------",
          
    "\n  BROKER INFORMATION:",
          
    "\n    Broker Company:           "AccountInfoString(ACCOUNT_COMPANY),
          
    "\n------------------------------------------------",
          
    "\n  ACCOUNT INFORMATION:",
          
    "\n    Account Type:              "AccountInfoString(ACCOUNT_SERVER),
          
    "\n    Account Name:              "AccountInfoString(ACCOUNT_NAME),
          
    "\n    Account Number:            ", (long)AccountInfoInteger(ACCOUNT_LOGIN),
          
    "\n    Account Leverage:          ", (string)AccountInfoInteger(ACCOUNT_LEVERAGE),
          
    "\n    Account Balance:           "DoubleToString(AccountInfoDouble(ACCOUNT_BALANCE), 2),
          
    "\n    Account Currency:          "AccountInfoString(ACCOUNT_CURRENCY),
          
    "\n    Account Equity:            "DoubleToString(AccountInfoDouble(ACCOUNT_EQUITY), 2),
          
    "\n------------------------------------------------",
          
    "\n  ORDERS INFORMATION:",
          
    "\n    Working & Pending Order:   ", (string)OrdersTotal(),
          
    "\n    Orders History Total:      ", (string)HistoryDealsTotal(),
          
    "\n------------------------------------------------",
          
    "\n  MARGIN INFORMATION:",
          
    "\n    Free Margin:                "DoubleToString(AccountInfoDouble(ACCOUNT_FREEMARGIN), 2),
          
    "\n    Used Margin:                "DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN), 2),
          
    "\n------------------------------------------------",
          
    "\n    PAIRS:                      "_Symbol,
          
    "\n    SPREAD:                     ", (string)(SymbolInfoInteger(_SymbolSYMBOL_SPREAD)), " points",
          
    "\n    Min Lot:                    "DoubleToString(SymbolInfoDouble(_SymbolSYMBOL_VOLUME_MIN), 2),
          
    "\n    Max Lot:                    "DoubleToString(SymbolInfoDouble(_SymbolSYMBOL_VOLUME_MAX), 2),
          
    "\n------------------------------------------------",
          
    "\n  Actual Server Time:           "TimeToString(TimeCurrent(), TIME_DATE TIME_SECONDS),
          
    "\n------------------------------------------------"
       
    );

       
    // Get Moving Averages (example using built-in iMA)
    // Calculate Moving Averages
    double MA1 iMA(_SymbolPERIOD_CURRENTPeriod1MA_SHIFT1MA_METHOD1PRICE_CLOSE0);
    double MA2 iMA(_SymbolPERIOD_CURRENTPeriod2MA_SHIFT2MA_METHOD2PRICE_CLOSE0);

    // Adjusted values with Dalta
    double ld_16 MA2 Dalta _Point;
    double ld_24 MA1 Dalta _Point;

    // Count open positions for this magic number
    int li_32 OrdersTotals(magic);   // <-- This needs to be adapted for MT5
    double ld_36 Profit(magic);      // <-- You already have MT5 version

    // Close BUY positions if condition met
    if (MA1 MA2 && ld_36 AmountmoneyLose && li_32 != 0)
    {
       
    closebuy(magic);                  // MT5 version already written
       
    DeletePendingOrdersbuy(magic);    // MT5 version already written
       
    return;
    }

    // Close SELL positions if condition met
    if (MA1 MA2 && ld_36 AmountmoneyLose && li_32 != 0)
    {
       
    closesell(magic);                 // MT5 version already written
       
    DeletePendingOrderssell(magic);   // MT5 version already written
       
    return;
    }

    // No trade if MA conditions not met
    if (MA1 ld_16 && li_32 == && Tradebuy)   return;
    if (
    MA2 ld_24 && li_32 == && Tradesell)  return;

    // Prevent both buy and sell from running on same chart
    if (Tradesell && Tradebuy)
    {
       
    Alert("Tradebuy=true and Tradesell=true - Cannot execute both directions on same chart");
       return;
    }

    ////

    void ExecuteOrders()
    {
       
    Ticket();
       
    double l_lots_44 getlot();
       
    int li_52 TP();
       
    int li_56 Step();

       
    double ask SymbolInfoDouble(_SymbolSYMBOL_ASK);
       
    double bid SymbolInfoDouble(_SymbolSYMBOL_BID);

       if (
    g_ticket_860 == 0)
       {
          if (
    g_ticket_876 != 0trade.OrderDelete(g_ticket_876);
          
    g_price_828 ask gi_80 _Point;
          if (
    gi_80 <= 0g_price_828 0;
          
    g_price_844 ask li_52 _Point;
          if (
    Tradebuy)
             
    trade.Buy(Lot1_Symbolaskg_price_828g_price_844"magic = " IntegerToString(magic));
       }

       if (
    g_ticket_864 == 0)
       {
          if (
    g_ticket_880 != 0trade.OrderDelete(g_ticket_880);
          
    g_price_836 bid gi_80 _Point;
          if (
    gi_80 <= 0g_price_836 0;
          
    g_price_852 bid li_52 _Point;
          if (
    Tradesell)
             
    trade.Sell(Lot1_Symbolbidg_price_836g_price_852"magic = " IntegerToString(magic));
       }

       if (
    g_ticket_860 != && g_ticket_876 == 0)
       {
          
    g_price_812 g_ord_open_price_924 li_56 _Point;
          
    g_price_828 g_price_812 gi_80 _Point;
          if (
    gi_80 <= 0g_price_828 0;
          
    g_price_844 g_price_812 li_52 _Point;
          
    trade.BuyLimit(l_lots_44g_price_812_Symbolg_price_828g_price_844ORDER_TIME_GTC0"magic = " IntegerToString(magic));
       }

       if (
    g_ticket_864 != && g_ticket_880 == 0)
       {
          
    g_price_812 g_ord_open_price_932 li_56 _Point;
          
    g_price_836 g_price_812 gi_80 _Point;
          if (
    gi_80 <= 0gi_80 0;
          
    g_price_852 g_price_812 li_52 _Point;
          
    trade.SellLimit(l_lots_44g_price_812_Symbolg_price_836g_price_852ORDER_TIME_GTC0"magic = " IntegerToString(magic));
       }

       
    TrailingStopTp(g_ord_open_price_924g_ord_takeprofit_884g_ord_open_price_932g_ord_takeprofit_892g_ticket_860g_ticket_864);

       if (!
    MQLInfoInteger(MQL_TESTER))
       {
          
    objectCreate("Info"24010"-"gi_1036"Arial"gi_972);
          
    objectCreate("Info1"24010"-"gi_1036"Arial"gi_972);
          
    objectCreate("Mode"84030"-"gi_1036"Arial"gi_972);
          
    objectCreate("Risk"5070"-"gi_1036"Arial"gi_972);

          
    long chart_id ChartID();

          if (
    MA1 MA2)
             
    ObjectSetString(chart_id"Info"OBJPROP_TEXT"The Two MA Indicator Confirm The Buy Mode");
          else if (
    MA2 MA1)
             
    ObjectSetString(chart_id"Info1"OBJPROP_TEXT"The Two MA Indicator Confirm The Sell Mode");

          if (
    Tradesell)
             
    ObjectSetString(chart_id"Mode"OBJPROP_TEXT"Sell Mode ");
          else if (
    Tradebuy)
             
    ObjectSetString(chart_id"Mode"OBJPROP_TEXT"Buy Mode");

          if ((
    MA1 MA2 && g_ticket_864 != 0) || (g_ticket_860 != && MA1 MA2))
             
    ObjectSetString(chart_id"Risk"OBJPROP_TEXT"Risk!!!! waiting for Closeorders Mode");
       }
    }
    ////////////////
    //////////////

    int OrdersTotals(int a_magic_0)
    {
       
    int count 0;
       
    int total PositionsTotal();
       
       for(
    int i 0totali++)
       {
          if(
    PositionSelectByIndex(i))
          {
             
    long magic;
             
    string sym;
             
    long type;
             
             
    PositionGetInteger(POSITION_MAGICmagic);
             
    PositionGetString(POSITION_SYMBOLsym);
             
    PositionGetInteger(POSITION_TYPEtype);
             
             if(
    magic == a_magic_0 && sym == _Symbol && 
                (
    type == POSITION_TYPE_BUY || type == POSITION_TYPE_SELL))
             {
                
    count++;
             }
          }
       }
       return 
    count;
    }
    ////////
    // Example arrays (fill with your Lot1..Lot40 values)
    double LotsArray[40] = { Lot1Lot2Lot3/* ... */ Lot40 };
    double TPArray[40]   = { TP1TP2TP3/* ... */ TP40 };
    double StepArray[40] = { step1step2step3/* ... */ step40 };

    double getlot()
    {
       
    int idx OrdersTotals(magic);
       if(
    idx >= && idx 40)
          return 
    LotsArray[idx];
       return 
    LotsArray[0]; // default fallback
    }

    double TP()
    {
       
    int idx OrdersTotals(magic);
       if(
    idx >= && idx 40)
          return 
    TPArray[idx];
       return 
    TPArray[0];
    }

    double Step()
    {
       
    int idx OrdersTotals(magic);
       if(
    idx >= && idx 40)
          return 
    StepArray[idx];
       return 
    StepArray[0];
    }

    ////////

    ///
    int DeletePendingOrdersSell(int a_magic_0)
    {
       
    int total OrdersTotal();

       for(
    int i total 1>= 0i--)
       {
          if(
    OrderSelect(iSELECT_BY_POS))
          {
             
    long magic;
             
    string sym;
             
    long type;
             
    ulong ticket;

             
    OrderGetInteger(ORDER_MAGICmagic);
             
    OrderGetString(ORDER_SYMBOLsym);
             
    OrderGetInteger(ORDER_TYPEtype);
             
    ticket OrderGetInteger(ORDER_TICKET);

             if(
    magic == a_magic_0 && sym == _Symbol && type == ORDER_TYPE_SELL_LIMIT)
             {
                if(!
    OrderDelete(ticket))
                   Print(
    "Failed to delete order "ticket" Error: "GetLastError());
             }
          }
       }
       return 
    0;
    }
    ///
    ///
    int DeletePendingOrdersBuy(int a_magic_0)
    {
       
    int total OrdersTotal();

       for(
    int i total 1>= 0i--)
       {
          if(
    OrderSelect(iSELECT_BY_POS))
          {
             
    long magic;
             
    string sym;
             
    long type;
             
    ulong ticket;

             
    OrderGetInteger(ORDER_MAGICmagic);
             
    OrderGetString(ORDER_SYMBOLsym);
             
    OrderGetInteger(ORDER_TYPEtype);
             
    ticket OrderGetInteger(ORDER_TICKET);

             if(
    magic == a_magic_0 && sym == _Symbol && type == ORDER_TYPE_BUY_LIMIT)
             {
                if(!
    OrderDelete(ticket))
                   Print(
    "Failed to delete order "ticket" Error: "GetLastError());
             }
          }
       }
       return 
    0;
    }

    /////

    void CloseBuy(int a_magic_0)
    {
       
    int total PositionsTotal();

       for(
    int i total 1>= 0i--)
       {
          
    string sym;
          
    long magic;
          
    long type;

          
    // Select the position
          
    if(PositionSelectByIndex(i))
          {
             
    PositionGetString(POSITION_SYMBOLsym);
             
    PositionGetInteger(POSITION_MAGICmagic);
             
    PositionGetInteger(POSITION_TYPEtype);

             
    // Check symbol, magic number, and position type (buy)
             
    if(sym == _Symbol && magic == a_magic_0 && type == POSITION_TYPE_BUY)
             {
                
    double volume PositionGetDouble(POSITION_VOLUME);

                
    // Close the position
                
    if(!trade.PositionClose(sym))
                   Print(
    "Failed to close BUY position on "sym
                         
    " Error: "GetLastError());
             }
          }
       }
    }

    ///

    void CloseSell(int a_magic_0)
    {
       
    int total PositionsTotal();

       for(
    int i total 1>= 0i--)
       {
          
    string sym;
          
    long magic;
          
    long type;

          
    // Select position
          
    if(PositionSelectByIndex(i))
          {
             
    PositionGetString(POSITION_SYMBOLsym);
             
    PositionGetInteger(POSITION_MAGICmagic);
             
    PositionGetInteger(POSITION_TYPEtype);

             
    // Check symbol, magic number, and SELL type
             
    if(sym == _Symbol && magic == a_magic_0 && type == POSITION_TYPE_SELL)
             {
                
    // Close position
                
    if(!trade.PositionClose(sym))
                   Print(
    "Failed to close SELL position on "sym
                         
    " Error: "GetLastError());
             }
          }
       }
    }



    ///



    double Profit(int a_magic_0)
    {
       
    double total_profit 0;
       
    int total_positions PositionsTotal();

       for(
    int i 0total_positionsi++)
       {
          
    string sym;
          
    long magic;
          
    long type;
          
    double profit;

          if(
    PositionSelectByIndex(i))
          {
             
    PositionGetString(POSITION_SYMBOLsym);
             
    PositionGetInteger(POSITION_MAGICmagic);
             
    PositionGetInteger(POSITION_TYPEtype);
             
    PositionGetDouble(POSITION_PROFITprofit);

             
    // Ensure magic number and symbol match
             
    if(sym == _Symbol && magic == a_magic_0 &&
                (
    type == POSITION_TYPE_BUY || type == POSITION_TYPE_SELL))
             {
                
    total_profit += profit;
             }
          }
       }

       return 
    total_profit;
    }
    /////

    double TrailingStopTp(double ad_0double ad_8double ad_16double ad_24int ai_32int ai_36)
    {
       
    double l_ord_takeprofit_40;
       
    double l_price_48;
       
    double l_ord_takeprofit_56;
       
    double l_price_64;

       for(
    int i 0PositionsTotal(); i++)
       {
          
    string sym;
          
    long magic_numbertype;
          
    double open_pricestop_losstake_profit;

          if(
    PositionSelectByIndex(i))
          {
             
    PositionGetString(POSITION_SYMBOLsym);
             
    PositionGetInteger(POSITION_MAGICmagic_number);
             
    PositionGetInteger(POSITION_TYPEtype);
             
    PositionGetDouble(POSITION_PRICE_OPENopen_price);
             
    PositionGetDouble(POSITION_SLstop_loss);
             
    PositionGetDouble(POSITION_TPtake_profit);

             
    // BUY trailing logic
             
    if(sym == _Symbol && type == POSITION_TYPE_BUY && ai_32 != && magic_number == magic)
             {
                
    l_price_48 ad_0 gi_80 _Point;
                if(
    gi_80 <= 0gi_80 0;

                if(
    ai_32 != (int)PositionGetInteger(POSITION_TICKET))
                   
    l_ord_takeprofit_40 ad_8;
                else
                   
    l_ord_takeprofit_40 take_profit;

                if(
    l_ord_takeprofit_40 != take_profit || l_price_48 != stop_loss)
                   
    trade.PositionModify(syml_price_48l_ord_takeprofit_40);
             }

             
    // SELL trailing logic
             
    if(sym == _Symbol && type == POSITION_TYPE_SELL && ai_36 != && magic_number == magic)
             {
                
    l_price_64 ad_16 gi_80 _Point;
                if(
    gi_80 <= 0l_price_64 0;

                if(
    ai_36 != (int)PositionGetInteger(POSITION_TICKET))
                   
    l_ord_takeprofit_56 ad_24;
                else
                   
    l_ord_takeprofit_56 take_profit;

                if(
    l_ord_takeprofit_56 != take_profit || l_price_64 != stop_loss)
                   
    trade.PositionModify(syml_price_64l_ord_takeprofit_56);
             }
          }
       }

       return 
    0.0;
    }



    ////

    void Ticket()
    {
       
    g_ticket_860 0;
       
    g_ticket_864 0;
       
    gi_unused_868 0;
       
    gi_unused_872 0;
       
    g_ticket_876 0;
       
    g_ticket_880 0;
       
    g_ord_takeprofit_884 0;
       
    g_ord_takeprofit_892 0;
       
    g_ord_lots_900 0;
       
    g_ord_lots_908 0;
       
    g_ord_lots_916 0;
       
    g_ord_open_price_924 0;
       
    g_ord_open_price_932 0;
       
    gd_940 0;
       
    gd_948 0;

       
    // === Open positions loop ===
       
    for(int i 0PositionsTotal(); i++)
       {
          if(
    PositionSelectByIndex(i))
          {
             
    string sym;
             
    long magic_numbertype;
             
    double lotsopen_pricetp;

             
    PositionGetString(POSITION_SYMBOLsym);
             
    PositionGetInteger(POSITION_MAGICmagic_number);
             
    PositionGetInteger(POSITION_TYPEtype);
             
    PositionGetDouble(POSITION_VOLUMElots);
             
    PositionGetDouble(POSITION_PRICE_OPENopen_price);
             
    PositionGetDouble(POSITION_TPtp);

             
    ulong ticket = (ulong)PositionGetInteger(POSITION_TICKET);

             if(
    sym == _Symbol && magic_number == magic)
             {
                
    // BUY
                
    if(type == POSITION_TYPE_BUY && g_ticket_860 < (int)ticket)
                {
                   
    g_ord_lots_900 lots;
                   
    g_ord_open_price_924 open_price;
                   
    g_ticket_860 = (int)ticket;
                   
    g_ord_takeprofit_884 tp;
                   if(
    lots == Lot1gd_940 open_price gi_80 _Point;
                }
                
    // SELL
                
    if(type == POSITION_TYPE_SELL && g_ticket_864 < (int)ticket)
                {
                   
    g_ord_lots_908 lots;
                   
    g_ord_open_price_932 open_price;
                   
    g_ticket_864 = (int)ticket;
                   
    g_ord_takeprofit_892 tp;
                   if(
    lots == Lot1gd_948 open_price gi_80 _Point;
                }
             }
          }
       }

       
    // === Pending orders loop ===
       
    for(int i 0OrdersTotal(); i++)
       {
          if(
    OrderSelect(iSELECT_BY_INDEX))
          {
             
    string sym;
             
    long magic_numbertype;
             
    double lots;

             
    OrderGetString(ORDER_SYMBOLsym);
             
    OrderGetInteger(ORDER_MAGICmagic_number);
             
    OrderGetInteger(ORDER_TYPEtype);
             
    OrderGetDouble(ORDER_VOLUME_CURRENTlots);

             
    ulong ticket = (ulong)OrderGetInteger(ORDER_TICKET);

             if(
    sym == _Symbol && magic_number == magic)
             {
                if(
    type == ORDER_TYPE_BUY_LIMIT)
                {
                   
    g_ticket_876 = (int)ticket;
                   
    g_ord_lots_916 lots;
                }
                if(
    type == ORDER_TYPE_SELL_LIMIT)
                {
                   
    g_ticket_880 = (int)ticket;
                   
    g_ord_lots_916 lots;
                }
             }
          }
       }


  9. #9
    الصورة الرمزية mr_gentle30
    mr_gentle30 غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Aug 2013
    الإقامة
    الأردن
    المشاركات
    124

    افتراضي

    السلام عليكم
    بالتوفيق
    الملفات المرفقة الملفات المرفقة

  10. #10
    الصورة الرمزية lolo_m
    lolo_m غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Aug 2025
    الإقامة
    تركيا
    المشاركات
    1

    Post

    كود:
    #property copyright "Copyright © 2009, Trader12."
    #property link "Trader12"
    
    #include <Trade\Trade.mqh>
    CTrade trade;
    
    input string Info = "If Your Broker Allwed Hedge";
    input string Info_1 = "You Cant Choose BUY & SELL In one Chart";
    input string Info_2 = "You Must Open Two Chart If Use BUY & SELL In One Time";
    input string Info_3 = "You Must Change Magic Number If Use BUY & SELL & Pair";
    
    input bool Tradebuy = true;
    input bool Tradesell = true;
    
    input double AmountmoneyLose = 10;
    input int MagicNumber = 9999;
    int gi_80 = 5000; // stays normal variable, not input
    input int slipp = 3;
    input int Dalta = 5;
    
    input string Set_MA_1 = "Moving Average 1";
    input int Period1 = 13;
    input int MA_SHIFT1 = 0;
    input int MA_METHOD1= 1;
    
    input string Set_MA_2 = "Moving Average 2";
    input int Period2 = 21;
    input int MA_SHIFT2 = 0;
    input int MA_METHOD2= 1;
    
    input string Set_Double = "You Can Choose Lot & Step & Target Profit For 40 Double";
    
    input double Lot1 = 0.01;
    input int step1 = 200;
    input int TP1 = 200;
    
    input double Lot2 = 0.01;
    input int step2 = 200;
    input int TP2 = 200;
    
    input double Lot3 = 0.02;
    input int step3 = 200;
    input int TP3 = 200;
    
    input double Lot4 = 0.04;
    input int step4 = 200;
    input int TP4 = 200;
    
    input double Lot5 = 0.08;
    input int step5 = 200;
    input int TP5 = 200;
    
    input double Lot6 = 0.16;
    input int step6 = 200;
    input int TP6 = 200;
    
    input double Lot7 = 0.30;
    input int step7 = 200;
    input int TP7 = 200;
    
    input double Lot8 = 0.60;
    input int step8 = 200;
    input int TP8 = 200;
    
    input double Lot9 = 0.68;
    input int step9 = 200;
    input int TP9 = 200;
    
    input double Lot10 = 0.76;
    input int step10 = 20;
    input int TP10 = 30;
    
    input double Lot11 = 0.84;
    input int step11 = 20;
    input int TP11 = 35;
    
    input double Lot12 = 0.92;
    input int step12 = 20;
    input int TP12 = 40;
    
    input double Lot13 = 1.00;
    input int step13 = 20;
    input int TP13 = 45;
    
    input double Lot14 = 1.08;
    input int step14 = 20;
    input int TP14 = 50;
    
    input double Lot15 = 1.14;
    input int step15 = 20;
    input int TP15 = 55;
    
    input double Lot16 = 1.22;
    input int step16 = 20;
    input int TP16 = 60;
    
    input double Lot17 = 1.30;
    input int step17 = 20;
    input int TP17 = 65;
    
    input double Lot18 = 1.38;
    input int step18 = 20;
    input int TP18 = 70;
    
    input double Lot19 = 1.46;
    input int step19 = 20;
    input int TP19 = 75;
    
    input double Lot20 = 1.54;
    input int step20 = 20;
    input int TP20 = 80;
    
    input double Lot21 = 6.8;
    input int step21 = 500;
    input int TP21 = 40;
    
    input double Lot22 = 6.8;
    input int step22 = 30;
    input int TP22 = 40;
    
    input double Lot23 = 6.8;
    input int step23 = 30;
    input int TP23 = 40;
    
    input double Lot24 = 6.8;
    input int step24 = 30;
    input int TP24 = 40;
    
    input double Lot25 = 6.8;
    input int step25 = 30;
    input int TP25 = 40;
    
    input double Lot26 = 6.8;
    input int step26 = 30;
    input int TP26 = 40;
    
    input double Lot27 = 6.8;
    input int step27 = 30;
    input int TP27 = 40;
    
    input double Lot28 = 6.8;
    input int step28 = 30;
    input int TP28 = 40;
    
    input double Lot29 = 6.8;
    input int step29 = 30;
    input int TP29 = 40;
    
    input double Lot30 = 6.8;
    input int step30 = 30;
    input int TP30 = 40;
    
    input double Lot31 = 6.8;
    input int step31 = 30;
    input int TP31 = 40;
    
    input double Lot32 = 6.8;
    input int step32 = 30;
    input int TP32 = 40;
    
    input double Lot33 = 6.8;
    input int step33 = 30;
    input int TP33 = 40;
    
    input double Lot34 = 6.8;
    input int step34 = 30;
    input int TP34 = 40;
    
    input double Lot35 = 6.8;
    input int step35 = 30;
    input int TP35 = 40;
    
    input double Lot36 = 6.8;
    input int step36 = 30;
    input int TP36 = 40;
    
    input double Lot37 = 6.8;
    input int step37 = 30;
    input int TP37 = 40;
    
    input double Lot38 = 6.8;
    input int step38 = 30;
    input int TP38 = 40;
    
    input double Lot39 = 6.8;
    input int step39 = 30;
    input int TP39 = 40;
    
    input double Lot40 = 6.8;
    input int step40 = 30;
    input int TP40 = 40;
    
    
    double g_price_812;
    double g_price_828;
    double g_price_836;
    double g_price_844;
    double g_price_852;
    ulong g_ticket_860 = 0;
    ulong g_ticket_864 = 0;
    int gi_unused_868 = 0;
    int gi_unused_872 = 0;
    ulong g_ticket_876 = 0;
    ulong g_ticket_880 = 0;
    double g_ord_takeprofit_884 = 0.0;
    double g_ord_takeprofit_892 = 0.0;
    double g_ord_lots_900 = 0.0;
    double g_ord_lots_908 = 0.0;
    double g_ord_lots_916 = 0.0;
    double g_ord_open_price_924 = 0.0;
    double g_ord_open_price_932 = 0.0;
    double gd_940 = 0.0;
    double gd_948 = 0.0;
    double gd_unused_956 = 0.0;
    int gi_972 = 16711680;
    int gi_1036 = 10;
    
    double LotsArray[40] = { Lot1, Lot2, Lot3, Lot4, Lot5, Lot6, Lot7, Lot8, Lot9, Lot10,
     Lot11, Lot12, Lot13, Lot14, Lot15, Lot16, Lot17, Lot18, Lot19, Lot20,
     Lot21, Lot22, Lot23, Lot24, Lot25, Lot26, Lot27, Lot28, Lot29, Lot30,
     Lot31, Lot32, Lot33, Lot34, Lot35, Lot36, Lot37, Lot38, Lot39, Lot40 };
    
    int TPArray[40] = { TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9, TP10,
     TP11, TP12, TP13, TP14, TP15, TP16, TP17, TP18, TP19, TP20,
     TP21, TP22, TP23, TP24, TP25, TP26, TP27, TP28, TP29, TP30,
     TP31, TP32, TP33, TP34, TP35, TP36, TP37, TP38, TP39, TP40 };
    
    int StepArray[40] = { step1, step2, step3, step4, step5, step6, step7, step8, step9, step10,
     step11, step12, step13, step14, step15, step16, step17, step18, step19, step20,
     step21, step22, step23, step24, step25, step26, step27, step28, step29, step30,
     step31, step32, step33, step34, step35, step36, step37, step38, step39, step40 };
    
    int ma1_handle = INVALID_HANDLE;
    int ma2_handle = INVALID_HANDLE;
    
    void objectCreate(
     string name,
     int x,
     int y,
     string text = "-",
     int fontsize = 40,
     string fontname = "Arial",
     color col = clrWhite,
     int corner = CORNER_LEFT_UPPER
    )
    {
     long chart_id = ChartID();
     int window = 0; // main window in EA
    
     // Delete old object if exists (avoid "already exists" errors)
     if(ObjectFind(chart_id, name) >= 0)
     ObjectDelete(chart_id, name);
    
     // Create label
     if(!ObjectCreate(chart_id, name, OBJ_LABEL, window, 0, 0))
     {
     Print("❌ Failed to create label: ", name);
     return;
     }
    
     // Set label properties
     ObjectSetInteger(chart_id, name, OBJPROP_CORNER, corner);
     ObjectSetInteger(chart_id, name, OBJPROP_XDISTANCE, x);
     ObjectSetInteger(chart_id, name, OBJPROP_YDISTANCE, y);
     ObjectSetInteger(chart_id, name, OBJPROP_COLOR, col);
     ObjectSetInteger(chart_id, name, OBJPROP_FONTSIZE, fontsize);
     ObjectSetString(chart_id, name, OBJPROP_FONT, fontname);
     ObjectSetString(chart_id, name, OBJPROP_TEXT, text);
    }
    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit()
    {
     trade.SetExpertMagicNumber(MagicNumber);
     ulong dev = (ulong)slipp;
     trade.SetDeviationInPoints(dev);
     gd_unused_956 = Lot1;
    
     ma1_handle = iMA(_Symbol, PERIOD_CURRENT, Period1, MA_SHIFT1, (ENUM_MA_METHOD)MA_METHOD1, PRICE_CLOSE);
     if(ma1_handle == INVALID_HANDLE)
     {
     Print("Failed to create MA1 handle");
     return(INIT_FAILED);
     }
    
     ma2_handle = iMA(_Symbol, PERIOD_CURRENT, Period2, MA_SHIFT2, (ENUM_MA_METHOD)MA_METHOD2, PRICE_CLOSE);
     if(ma2_handle == INVALID_HANDLE)
     {
     Print("Failed to create MA2 handle");
     return(INIT_FAILED);
     }
    
     return(INIT_SUCCEEDED);
    }
    
    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
     ObjectDelete(ChartID(), "Info");
     ObjectDelete(ChartID(), "Info1");
     ObjectDelete(ChartID(), "Mode");
     ObjectDelete(ChartID(), "Risk");
     Comment("");
    
     if(ma1_handle != INVALID_HANDLE) IndicatorRelease(ma1_handle);
     if(ma2_handle != INVALID_HANDLE) IndicatorRelease(ma2_handle);
    }
    
    //+------------------------------------------------------------------+
    //| Expert tick function |
    //+------------------------------------------------------------------+
    void OnTick()
    {
     // Account information
     Comment(
     "\n SolMoon",
     "\n H$H ",
     "\n------------------------------------------------",
     "\n BROKER INFORMATION:",
     "\n Broker Company: ", AccountInfoString(ACCOUNT_COMPANY),
     "\n------------------------------------------------",
     "\n ACCOUNT INFORMATION:",
     "\n Account Type: ", AccountInfoString(ACCOUNT_SERVER),
     "\n Account Name: ", AccountInfoString(ACCOUNT_NAME),
     "\n Account Number: ", (long)AccountInfoInteger(ACCOUNT_LOGIN),
     "\n Account Leverage: ", (string)AccountInfoInteger(ACCOUNT_LEVERAGE),
     "\n Account Balance: ", DoubleToString(AccountInfoDouble(ACCOUNT_BALANCE), 2),
     "\n Account Currency: ", AccountInfoString(ACCOUNT_CURRENCY),
     "\n Account Equity: ", DoubleToString(AccountInfoDouble(ACCOUNT_EQUITY), 2),
     "\n------------------------------------------------",
     "\n ORDERS INFORMATION:",
     "\n Working & Pending Order: ", (string)OrdersTotal(),
     "\n Orders History Total: ", (string)HistoryDealsTotal(),
     "\n------------------------------------------------",
     "\n MARGIN INFORMATION:",
     "\n Free Margin: ", DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN_FREE), 2),
     "\n Used Margin: ", DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN), 2),
     "\n------------------------------------------------",
     "\n PAIRS: ", _Symbol,
     "\n SPREAD: ", (string)(SymbolInfoInteger(_Symbol, SYMBOL_SPREAD)), " points",
     "\n Min Lot: ", DoubleToString(SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN), 2),
     "\n Max Lot: ", DoubleToString(SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX), 2),
     "\n------------------------------------------------",
     "\n Actual Server Time: ", TimeToString(TimeCurrent(), TIME_DATE | TIME_SECONDS),
     "\n------------------------------------------------"
     );
    
     // Calculate Moving Averages
     double ma1_buffer[1], ma2_buffer[1];
     if(CopyBuffer(ma1_handle, 0, 0, 1, ma1_buffer) != 1)
     {
     Print("Failed to copy MA1 buffer");
     return;
     }
     if(CopyBuffer(ma2_handle, 0, 0, 1, ma2_buffer) != 1)
     {
     Print("Failed to copy MA2 buffer");
     return;
     }
     double MA1 = ma1_buffer[0];
     double MA2 = ma2_buffer[0];
    
     // Adjusted values with Dalta
     double ld_16 = MA2 + Dalta * _Point;
     double ld_24 = MA1 + Dalta * _Point;
    
     // Count open positions for this magic number
     int li_32 = OrdersTotals(MagicNumber);
     double ld_36 = Profit(MagicNumber);
    
     // Close BUY positions if condition met
     if (MA1 < MA2 && ld_36 > AmountmoneyLose && li_32 != 0)
     {
     CloseBuy(MagicNumber);
     DeletePendingOrdersBuy(MagicNumber);
     return;
     }
    
     // Close SELL positions if condition met
     if (MA1 > MA2 && ld_36 > AmountmoneyLose && li_32 != 0)
     {
     CloseSell(MagicNumber);
     DeletePendingOrdersSell(MagicNumber);
     return;
     }
    
     // No trade if MA conditions not met
     if (MA1 < ld_16 && li_32 == 0 && Tradebuy) return;
     if (MA2 < ld_24 && li_32 == 0 && Tradesell) return;
    
     // Prevent both buy and sell from running on same chart
     if (Tradesell && Tradebuy)
     {
     Alert("Tradebuy=true and Tradesell=true - Cannot execute both directions on same chart");
     return;
     }
    
     ExecuteOrders(MA1, MA2);
    }
    
    void ExecuteOrders(double MA1, double MA2)
    {
     Ticket();
     double l_lots_44 = getlot();
     int li_52 = TP();
     int li_56 = Step();
    
     double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
     double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
    
     if (g_ticket_860 == 0)
     {
     if (g_ticket_876 != 0) trade.OrderDelete(g_ticket_876);
     g_price_828 = ask - gi_80 * _Point;
     if (gi_80 <= 0) g_price_828 = 0;
     g_price_844 = ask + li_52 * _Point;
     if (Tradebuy)
     trade.Buy(Lot1, _Symbol, ask, g_price_828, g_price_844, "MagicNumber = " + IntegerToString(MagicNumber));
     }
    
     if (g_ticket_864 == 0)
     {
     if (g_ticket_880 != 0) trade.OrderDelete(g_ticket_880);
     g_price_836 = bid + gi_80 * _Point;
     if (gi_80 <= 0) g_price_836 = 0;
     g_price_852 = bid - li_52 * _Point;
     if (Tradesell)
     trade.Sell(Lot1, _Symbol, bid, g_price_836, g_price_852, "MagicNumber = " + IntegerToString(MagicNumber));
     }
    
     if (g_ticket_860 != 0 && g_ticket_876 == 0)
     {
     g_price_812 = g_ord_open_price_924 - li_56 * _Point;
     g_price_828 = g_price_812 - gi_80 * _Point;
     if (gi_80 <= 0) g_price_828 = 0;
     g_price_844 = g_price_812 + li_52 * _Point;
     trade.BuyLimit(l_lots_44, g_price_812, _Symbol, g_price_828, g_price_844, ORDER_TIME_GTC, 0, "MagicNumber = " + IntegerToString(MagicNumber));
     }
    
     if (g_ticket_864 != 0 && g_ticket_880 == 0)
     {
     g_price_812 = g_ord_open_price_932 + li_56 * _Point;
     g_price_836 = g_price_812 + gi_80 * _Point;
     if (gi_80 <= 0) g_price_836 = 0;
     g_price_852 = g_price_812 - li_52 * _Point;
     trade.SellLimit(l_lots_44, g_price_812, _Symbol, g_price_836, g_price_852, ORDER_TIME_GTC, 0, "MagicNumber = " + IntegerToString(MagicNumber));
     }
    
     TrailingStopTp(g_ord_open_price_924, g_ord_takeprofit_884, g_ord_open_price_932, g_ord_takeprofit_892, g_ticket_860, g_ticket_864);
    
     if (!MQLInfoInteger(MQL_TESTER))
     {
     objectCreate("Info", 240, 10, "-", gi_1036, "Arial", gi_972);
     objectCreate("Info1", 240, 10, "-", gi_1036, "Arial", gi_972);
     objectCreate("Mode", 840, 30, "-", gi_1036, "Arial", gi_972);
     objectCreate("Risk", 50, 70, "-", gi_1036, "Arial", gi_972);
    
     long chart_id = ChartID();
    
     if (MA1 > MA2)
     ObjectSetString(chart_id, "Info", OBJPROP_TEXT, "The Two MA Indicator Confirm The Buy Mode");
     else if (MA2 < MA1)
     ObjectSetString(chart_id, "Info1", OBJPROP_TEXT, "The Two MA Indicator Confirm The Sell Mode");
    
     if (Tradesell)
     ObjectSetString(chart_id, "Mode", OBJPROP_TEXT, "Sell Mode ");
     else if (Tradebuy)
     ObjectSetString(chart_id, "Mode", OBJPROP_TEXT, "Buy Mode");
    
     if ((MA1 > MA2 && g_ticket_864 != 0) || (g_ticket_860 != 0 && MA1 < MA2))
     ObjectSetString(chart_id, "Risk", OBJPROP_TEXT, "Risk!!!! waiting for Closeorders Mode");
     }
    }
    
    int OrdersTotals(int a_magic_0)
    {
     int count = 0;
     int total = PositionsTotal();
     
     for(int i = 0; i < total; i++)
     {
     ulong ticket = PositionGetTicket(i);
     if(ticket != ULONG_MAX)
     {
     if(PositionSelectByTicket(ticket))
     {
     long magic = PositionGetInteger(POSITION_MAGIC);
     string sym = PositionGetString(POSITION_SYMBOL);
     long type = PositionGetInteger(POSITION_TYPE);
     
     if(magic == a_magic_0 && sym == _Symbol && 
     (type == POSITION_TYPE_BUY || type == POSITION_TYPE_SELL))
     {
     count++;
     }
     }
     }
     }
     return count;
    }
    
    double getlot()
    {
     int idx = OrdersTotals(MagicNumber);
     if(idx >= 0 && idx < 40)
     return LotsArray[idx];
     return LotsArray[0]; // default fallback
    }
    
    int TP()
    {
     int idx = OrdersTotals(MagicNumber);
     if(idx >= 0 && idx < 40)
     return TPArray[idx];
     return TPArray[0];
    }
    
    int Step()
    {
     int idx = OrdersTotals(MagicNumber);
     if(idx >= 0 && idx < 40)
     return StepArray[idx];
     return StepArray[0];
    }
    
    int DeletePendingOrdersSell(int a_magic_0)
    {
     int total = OrdersTotal();
    
     for(int i = 0; i < total; i++)
     {
     ulong ticket = OrderGetTicket(i);
     if(OrderSelect(ticket))
     {
     long magic = OrderGetInteger(ORDER_MAGIC);
     string sym = OrderGetString(ORDER_SYMBOL);
     long type = OrderGetInteger(ORDER_TYPE);
    
     if(magic == a_magic_0 && sym == _Symbol && type == ORDER_TYPE_SELL_LIMIT)
     {
     if(!trade.OrderDelete(ticket))
     Print("Failed to delete order ", ticket, " Error: ", GetLastError());
     }
     }
     }
     return 0;
    }
    
    int DeletePendingOrdersBuy(int a_magic_0)
    {
     int total = OrdersTotal();
    
     for(int i = 0; i < total; i++)
     {
     ulong ticket = OrderGetTicket(i);
     if(OrderSelect(ticket))
     {
     long magic = OrderGetInteger(ORDER_MAGIC);
     string sym = OrderGetString(ORDER_SYMBOL);
     long type = OrderGetInteger(ORDER_TYPE);
    
     if(magic == a_magic_0 && sym == _Symbol && type == ORDER_TYPE_BUY_LIMIT)
     {
     if(!trade.OrderDelete(ticket))
     Print("Failed to delete order ", ticket, " Error: ", GetLastError());
     }
     }
     }
     return 0;
    }
    
    void CloseBuy(int a_magic_0)
    {
     int total = PositionsTotal();
    
     for(int i = total - 1; i >= 0; i--)
     {
     ulong ticket = PositionGetTicket(i);
     if(ticket != ULONG_MAX)
     {
     if(PositionSelectByTicket(ticket))
     {
     string sym = PositionGetString(POSITION_SYMBOL);
     long magic = PositionGetInteger(POSITION_MAGIC);
     long type = PositionGetInteger(POSITION_TYPE);
    
     if(sym == _Symbol && magic == a_magic_0 && type == POSITION_TYPE_BUY)
     {
     if(!trade.PositionClose(ticket))
     Print("Failed to close BUY position ", ticket, " Error: ", GetLastError());
     }
     }
     }
     }
    }
    
    void CloseSell(int a_magic_0)
    {
     int total = PositionsTotal();
    
     for(int i = total - 1; i >= 0; i--)
     {
     ulong ticket = PositionGetTicket(i);
     if(ticket != ULONG_MAX)
     {
     if(PositionSelectByTicket(ticket))
     {
     string sym = PositionGetString(POSITION_SYMBOL);
     long magic = PositionGetInteger(POSITION_MAGIC);
     long type = PositionGetInteger(POSITION_TYPE);
    
     if(sym == _Symbol && magic == a_magic_0 && type == POSITION_TYPE_SELL)
     {
     if(!trade.PositionClose(ticket))
     Print("Failed to close SELL position ", ticket, " Error: ", GetLastError());
     }
     }
     }
     }
    }
    
    double Profit(int a_magic_0)
    {
     double total_profit = 0;
     int total_positions = PositionsTotal();
    
     for(int i = 0; i < total_positions; i++)
     {
     ulong ticket = PositionGetTicket(i);
     if(ticket != ULONG_MAX)
     {
     if(PositionSelectByTicket(ticket))
     {
     string sym = PositionGetString(POSITION_SYMBOL);
     long magic = PositionGetInteger(POSITION_MAGIC);
     long type = PositionGetInteger(POSITION_TYPE);
     double profit = PositionGetDouble(POSITION_PROFIT);
    
     if(sym == _Symbol && magic == a_magic_0 &&
     (type == POSITION_TYPE_BUY || type == POSITION_TYPE_SELL))
     {
     total_profit += profit;
     }
     }
     }
     }
    
     return total_profit;
    }
    
    double TrailingStopTp(double ad_0, double ad_8, double ad_16, double ad_24, ulong ai_32, ulong ai_36)
    {
     double l_ord_takeprofit_40;
     double l_price_48;
     double l_ord_takeprofit_56;
     double l_price_64;
    
     for(int i = 0; i < PositionsTotal(); i++)
     {
     ulong ticket = PositionGetTicket(i);
     if(ticket != ULONG_MAX)
     {
     if(PositionSelectByTicket(ticket))
     {
     string sym = PositionGetString(POSITION_SYMBOL);
     long magic_number = PositionGetInteger(POSITION_MAGIC);
     long type = PositionGetInteger(POSITION_TYPE);
     double open_price = PositionGetDouble(POSITION_PRICE_OPEN);
     double stop_loss = PositionGetDouble(POSITION_SL);
     double take_profit = PositionGetDouble(POSITION_TP);
    
     // BUY trailing logic
     if(sym == _Symbol && type == POSITION_TYPE_BUY && ai_32 != 0 && magic_number == MagicNumber)
     {
     l_price_48 = ad_0 - gi_80 * _Point;
     if(gi_80 <= 0) l_price_48 = 0;
    
     if(ai_32 != ticket)
     l_ord_takeprofit_40 = ad_8;
     else
     l_ord_takeprofit_40 = take_profit;
    
     if(l_ord_takeprofit_40 != take_profit || l_price_48 != stop_loss)
     trade.PositionModify(ticket, l_price_48, l_ord_takeprofit_40);
     }
    
     // SELL trailing logic
     if(sym == _Symbol && type == POSITION_TYPE_SELL && ai_36 != 0 && magic_number == MagicNumber)
     {
     l_price_64 = ad_16 + gi_80 * _Point;
     if(gi_80 <= 0) l_price_64 = 0;
    
     if(ai_36 != ticket)
     l_ord_takeprofit_56 = ad_24;
     else
     l_ord_takeprofit_56 = take_profit;
    
     if(l_ord_takeprofit_56 != take_profit || l_price_64 != stop_loss)
     trade.PositionModify(ticket, l_price_64, l_ord_takeprofit_56);
     }
     }
     }
     }
    
     return 0.0;
    }
    
    void Ticket()
    {
     g_ticket_860 = 0;
     g_ticket_864 = 0;
     gi_unused_868 = 0;
     gi_unused_872 = 0;
     g_ticket_876 = 0;
     g_ticket_880 = 0;
     g_ord_takeprofit_884 = 0;
     g_ord_takeprofit_892 = 0;
     g_ord_lots_900 = 0;
     g_ord_lots_908 = 0;
     g_ord_lots_916 = 0;
     g_ord_open_price_924 = 0;
     g_ord_open_price_932 = 0;
     gd_940 = 0;
     gd_948 = 0;
    
     // === Open positions loop ===
     for(int i = 0; i < PositionsTotal(); i++)
     {
     ulong ticket = PositionGetTicket(i);
     if(ticket != ULONG_MAX)
     {
     if(PositionSelectByTicket(ticket))
     {
     string sym = PositionGetString(POSITION_SYMBOL);
     long magic_number = PositionGetInteger(POSITION_MAGIC);
     long type = PositionGetInteger(POSITION_TYPE);
     double lots = PositionGetDouble(POSITION_VOLUME);
     double open_price = PositionGetDouble(POSITION_PRICE_OPEN);
     double tp = PositionGetDouble(POSITION_TP);
    
     if(sym == _Symbol && magic_number == MagicNumber)
     {
     // BUY
     if(type == POSITION_TYPE_BUY && g_ticket_860 < ticket)
     {
     g_ord_lots_900 = lots;
     g_ord_open_price_924 = open_price;
     g_ticket_860 = ticket;
     g_ord_takeprofit_884 = tp;
     if(lots == Lot1) gd_940 = open_price - gi_80 * _Point;
     }
     // SELL
     if(type == POSITION_TYPE_SELL && g_ticket_864 < ticket)
     {
     g_ord_lots_908 = lots;
     g_ord_open_price_932 = open_price;
     g_ticket_864 = ticket;
     g_ord_takeprofit_892 = tp;
     if(lots == Lot1) gd_948 = open_price + gi_80 * _Point;
     }
     }
     }
     }
     }
    
     // === Pending orders loop ===
     for(int i = 0; i < OrdersTotal(); i++)
     {
     ulong ticket = OrderGetTicket(i);
     if(OrderSelect(ticket))
     {
     string sym = OrderGetString(ORDER_SYMBOL);
     long magic_number = OrderGetInteger(ORDER_MAGIC);
     long type = OrderGetInteger(ORDER_TYPE);
     double lots = OrderGetDouble(ORDER_VOLUME_CURRENT);
    
     if(sym == _Symbol && magic_number == MagicNumber)
     {
     if(type == ORDER_TYPE_BUY_LIMIT)
     {
     g_ticket_876 = ticket;
     g_ord_lots_916 = lots;
     }
     if(type == ORDER_TYPE_SELL_LIMIT)
     {
     g_ticket_880 = ticket;
     g_ord_lots_916 = lots;
     }
     }
     }
     }
    }

  11. #11
    الصورة الرمزية abo3nod
    abo3nod غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    May 2016
    الإقامة
    السعودية
    المشاركات
    28

    افتراضي

    جاري العمل على الحل
    آخر تعديل بواسطة abo3nod ، 11-10-2025 الساعة 12:37 PM


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17