Convert a MT4 EA to a cTrader cBot

指定

Here is the code that needs to be converted:-


//+------------------------------------------------------------------+

//+                           Code generated using FxPro Quant 2.1.4 |

//+------------------------------------------------------------------+

#property strict


#define __STRATEGY_MAGIC 1001000000

#define __SLEEP_AFTER_EXECUTION_FAIL 400



struct InputsStr

  {

   string            _Currency;       // Symbol

   string            _TimeFrame;      // TimeFrame

   string               _Slowing;       // Slowing

   string               _Whole_Number_Input;       // Period

   string               _Grid_Points;       // Grid Points

   string            _SL_Percentage;       // SL Percentage

   string               _RSI_Buy_Limit;         // RSI Buy Limit

   string               _Sell_TP_in_Points;       // Sell TP in Points

   string               _Max_Days;        // Max Days

   string               _Stoc_Buy_Limit;        // Stoc Buy Limit

   string            _Mom_Buy_Limit;       // Mom Buy Limit

   string               _D_Period;         // D Period

   string               _Stoc_Sell_Limit;       // Stoc Sell Limit

   string               _RSI_Sell_Limit;        // RSI Sell Limit

   string            _Mom_Sell_Limit;        // Mom Sell Limit

   string               _Buy_TP_in_Points;        // Buy TP in Points

   string               _Max_Open_Trades;        // Max Open Trades

   string            _Lot_Percentage;       // Lot Percentage

  };

struct Inputs

  {

   string            _Currency;       // Symbol

   string            _TimeFrame;      // TimeFrame

   int               _Slowing;       // Slowing

   int               _Whole_Number_Input;       // Period

   int               _Grid_Points;       // Grid Points

   double            _SL_Percentage;       // SL Percentage

   int               _RSI_Buy_Limit;         // RSI Buy Limit

   int               _Sell_TP_in_Points;       // Sell TP in Points

   int               _Max_Days;        // Max Days

   int               _Stoc_Buy_Limit;        // Stoc Buy Limit

   double            _Mom_Buy_Limit;       // Mom Buy Limit

   int               _D_Period;         // D Period

   int               _Stoc_Sell_Limit;       // Stoc Sell Limit

   int               _RSI_Sell_Limit;        // RSI Sell Limit

   double            _Mom_Sell_Limit;        // Mom Sell Limit

   int               _Buy_TP_in_Points;        // Buy TP in Points

   int               _Max_Open_Trades;        // Max Open Trades

   double            _Lot_Percentage;       // Lot Percentage

  };


//Default Input variables

string _Currency ;

int  _TimeFrame;

int _Slowing;

int _Whole_Number_Input;

int _Grid_Points ;

double _SL_Percentage ;

int _RSI_Buy_Limit ;

int _Sell_TP_in_Points;

int _Max_Days ;

int _Stoc_Buy_Limit ;

double _Mom_Buy_Limit;

int _D_Period;

int _Stoc_Sell_Limit;

int _RSI_Sell_Limit ;

double _Mom_Sell_Limit;

int _Buy_TP_in_Points;

int _Max_Open_Trades ;

double _Lot_Percentage;


//Global declaration

double _Momentum;

double _Stochastic_3;

double _RSI;

bool _Compare_7;

bool _Compare_10;

bool _Compare_1;

bool _Compare_9;

bool _Compare_11;

double _Arithmetic;

bool _Compare_12;

bool _Compare_2;



Inputs inputsAct[] ;

InputsStr inputs[];


// Global Variables

input string _FileName="MRS14.csv" ; // Input File

input int    _GlobalMaxOrders=20;


//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int init()

  {

   if(ReadCSVFile())

     {

      if(ArraySize(inputsAct)<=0)

         return INIT_FAILED;

     }

   else

     {

      return INIT_FAILED ;

     }

   return(0);

  }


//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int start()

  {


   for(int i=0; i<ArraySize(inputsAct); i++)

     {

      SetSettings(inputsAct[i]._Currency);

      //Local declaration

      bool _Close_Position_1 = false;

      bool _Sell = false;

      bool _Buy = false;

      bool _Buy_2 = false;

      bool _Sell_2 = false;

      _Momentum = iMomentum(_Currency,_TimeFrame, _Whole_Number_Input, 0, 0);

      _Stochastic_3 = iStochastic(_Currency, _TimeFrame, _Whole_Number_Input, _D_Period, _Slowing, 0, 0, 0, 0);

      _RSI = iRSI(_Currency, _TimeFrame, _Whole_Number_Input,0, 0);


      _Compare_7 = (_RSI > _RSI_Sell_Limit);

      _Compare_10 = (_Momentum > _Mom_Sell_Limit);

      _Compare_1 = (_RSI < _RSI_Buy_Limit);

      _Compare_9 = (_Momentum < _Mom_Buy_Limit);

      _Compare_11 = (Number_of_Open_Trades(1,_Currency) < _Max_Open_Trades);

      _Arithmetic = ((_Grid_Points *

                      (-1)) *

                     (Number_of_Open_Trades(1,_Currency)));

      _Compare_12 = (_Stochastic_3 > _Stoc_Sell_Limit);

      _Compare_2 = (_Stochastic_3 < _Stoc_Buy_Limit);



      if((__OpenTime(1, _Currency) + 24*60*60 * (_Max_Days) < TimeCurrent()))

        {

         _Close_Position_1 = __isOpenedPosition(1, _Currency);

         if(_Close_Position_1)

           {

            int ticket = OrderTicket();

            int type = OrderType();

            double lots = OrderLots();

            string sym = OrderSymbol();

            _Close_Position_1 = OrderClose(ticket, lots, MarketInfo(sym, MODE_BID) + MarketInfo(sym, MODE_SPREAD) * MarketInfo(sym, MODE_POINT) * (type==1 ? 1:0), 0);

           }

        }


      if(GetGlobalOrders()>=_GlobalMaxOrders)

         return 0 ;


      if(((_Compare_7 &&

           (_Compare_12 &&

            !__selectOrderBySymbol(_Currency))) &&

          _Compare_10))

          

         _Sell = Sell(_Currency,1, ((_Lot_Percentage *

                           (AccountFreeMargin())) /

                          (100000)), 0, ((AccountFreeMargin() /

                                          ((100 /

                                            (_SL_Percentage)))) /

                                         (((_Lot_Percentage *

                                            (AccountFreeMargin())) /

                                           (100000)))), 0, _Sell_TP_in_Points, 5, _Max_Open_Trades, 0, "");


      if((((_Compare_2 &&

            !__selectOrderBySymbol(_Currency)) &&

           _Compare_1) &&

          _Compare_9))

          

         _Buy = Buy(_Currency,1, ((_Lot_Percentage *

                         (AccountFreeMargin())) /

                        (100000)), 0, ((AccountFreeMargin() /

                                        ((100 /

                                          (_SL_Percentage)))) /

                                       (((_Lot_Percentage *

                                          (AccountFreeMargin())) /

                                         (100000)))), 0, _Buy_TP_in_Points, 5, _Max_Open_Trades, 0, "");



      if((((((__selectOrderBySymbol(_Currency) &&

              ((_Arithmetic < 0) &&

               (__ProfitPoints(1, _Currency) < _Arithmetic))) &&

             _Compare_11) &&

            _Compare_2) &&

           _Compare_1) &&

          _Compare_9))

          

         _Buy_2 = Buy(_Currency,1, ((_Lot_Percentage *

                           (AccountFreeMargin())) /

                          (100000)), 0, ((AccountFreeMargin() /

                                          ((100 /

                                            (_SL_Percentage)))) /

                                         (((_Lot_Percentage *

                                            (AccountFreeMargin())) /

                                           (100000)))), 0, _Buy_TP_in_Points, 5, _Max_Open_Trades, 0, "");


      if((((((__selectOrderBySymbol(_Currency) &&

              ((_Arithmetic < 0) &&

               (__ProfitPoints(1, _Currency) < _Arithmetic))) &&

             _Compare_11) &&

            _Compare_12) &&

           _Compare_7) &&

          _Compare_10))

         _Sell_2 = Sell(_Currency,1, ((_Lot_Percentage *

                             (AccountFreeMargin())) /

                            (100000)), 0, ((AccountFreeMargin() /

                                            ((100 /

                                              (_SL_Percentage)))) /

                                           (((_Lot_Percentage *

                                              (AccountFreeMargin())) /

                                             (100000)))), 0, _Sell_TP_in_Points, 5, _Max_Open_Trades, 0, "");

     }



   return(0);

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool __selectOrderBySymbol(string symbol)

  {

   for(int i = 0; i < OrdersTotal(); i++)

     {

      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == symbol)

         return(true);

     }

   return(false);

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool __selectOrderByMagic(int magic, string symbol)

  {

   for(int i = 0; i < OrdersTotal(); i++)

     {

      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == __STRATEGY_MAGIC + magic && OrderSymbol() == symbol)

         return(true);

     }

   return(false);

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

datetime __OpenTime(int magic, string symbol)

  {

   if(!__selectOrderByMagic(magic, symbol))

      return(0);

   return(OrderOpenTime());

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double __ProfitPoints(int magic, string symbol)

  {

   if(!__selectOrderByMagic(magic, symbol))

      return(0);

   if(OrderType() == OP_BUY)

      return ((MarketInfo(OrderSymbol(),MODE_BID) - OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT));

   else

      if(OrderType() == OP_SELL)

         return ((OrderOpenPrice() - (MarketInfo(OrderSymbol(),MODE_ASK)))/MarketInfo(OrderSymbol(),MODE_POINT));

   return (0);

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool __isOpenedPosition(int magic, string symbol)

  {

   if(!__selectOrderByMagic(magic, symbol))

      return(false);

   return(OrderType()==OP_BUY || OrderType()==OP_SELL);

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int __Ticket(int magic, string symbol)

  {

   if(!__selectOrderByMagic(magic, symbol))

      return(0);

   return(OrderTicket());

  }




//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int Number_of_Open_Trades(int MagicIndex, string symbol)

  {

   int res = 0;

   for(int i=OrdersTotal()-1; i>=0; i--)

     {

      if(!OrderSelect(i, SELECT_BY_POS))

         continue;

      if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != symbol)

         continue;

      res ++;

     }

   return (res);

  }



//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool Sell(string symbol ,int MagicIndex, double Lots, int StopLossMethod, double StopLossPoints, int TakeProfitMethod, double TakeProfitPoints, int Slippage, int MaxOpenTrades,

          int MaxFrequencyMins, string TradeComment)

  {

   int digits=(int)MarketInfo(symbol,MODE_DIGITS);

   double points=MarketInfo(symbol,MODE_POINT);

   double bid=MarketInfo(symbol,MODE_BID);

   double ask=MarketInfo(symbol,MODE_ASK);

   

   static double pipSize = 0;

   if(pipSize == 0)

      pipSize = points * (1 + 9 * (digits == 3 || digits == 5));


   double sl = 0, tp = 0;

   double stopLossPoints = 0, takeProfitPoints = 0;


   int numberOfOpenTrades = 0;


   for(int i=OrdersTotal()-1; i>=0; i--)

     {

      if(!OrderSelect(i, SELECT_BY_POS))

         continue;

      if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != symbol)

         continue;

      numberOfOpenTrades ++;

     }


   if(MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades)

      return(false);


   if(MaxFrequencyMins  > 0)

     {

      int recentSeconds = MaxFrequencyMins * 60;


      for(int i=OrdersTotal()-1; i>=0; i--)

        {

         if(!OrderSelect(i, SELECT_BY_POS))

            continue;

         if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() !=symbol)

            continue;

         if(TimeCurrent() - OrderOpenTime() < recentSeconds)

            return(false);

        }


      int hstTotal=OrdersHistoryTotal();


      for(int i=hstTotal-1; i>=0; i--)

        {

         if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))

            continue;

         if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != symbol)

            continue;

         if(TimeCurrent() - OrderOpenTime() < recentSeconds)

            return(false);

         break;

        }

     }


   if(Lots < MarketInfo(symbol,MODE_MINLOT))

      return(false);


   if(AccountFreeMarginCheck(symbol, OP_SELL,Lots) <= 0)

     {

      Print("Sell order error: insufficient capital");

      return(false);

     }


   if(StopLossPoints > 0)

     {

      if(StopLossMethod == 0)

        {

         sl = NormalizeDouble(bid + StopLossPoints * points, digits);

         stopLossPoints = StopLossPoints;

        }

      else

         if(StopLossMethod == 1)

           {

            sl = NormalizeDouble(bid + StopLossPoints * pipSize, digits);

            stopLossPoints = StopLossPoints * (1 + 9 * (digits == 3 || digits == 5));

           }

         else

           {

            sl = StopLossPoints;

            stopLossPoints = (sl - bid)/points;

           }

     }


   if(TakeProfitPoints > 0)

     {

      if(TakeProfitMethod == 0)

        {

         tp = NormalizeDouble(bid - TakeProfitPoints * points, digits);

         takeProfitPoints = TakeProfitPoints;

        }

      else

         if(TakeProfitMethod == 1)

           {

            tp = NormalizeDouble(bid - TakeProfitPoints * pipSize, digits);

            takeProfitPoints = TakeProfitPoints * (1 + 9 * (digits == 3 || digits == 5));

           }

         else

           {

            tp = TakeProfitPoints;

            takeProfitPoints = (bid - tp)/Point;

           }

     }


   double stopLevel = MarketInfo(symbol,MODE_STOPLEVEL) + MarketInfo(symbol,MODE_SPREAD);


   if((sl > 0 && stopLossPoints <= stopLevel) || (tp > 0 && takeProfitPoints <= stopLevel))

     {

      Print("Cannot Sell: Stop loss and take profit must be at least "

            + DoubleToStr(MarketInfo(symbol,MODE_STOPLEVEL) + MarketInfo(symbol,MODE_SPREAD),0)

            + " points away from the current price");

      return (false);

     }


   RefreshRates();

   int result = OrderSend(symbol, OP_SELL, Lots, bid, Slippage, sl, tp, "FxProQuant" + "(" + WindowExpertName() + ") " + TradeComment,__STRATEGY_MAGIC + MagicIndex);


   if(result == -1)

     {

      Print("Failed to Sell: " + IntegerToString(GetLastError()));

      Sleep(__SLEEP_AFTER_EXECUTION_FAIL);

      return(false);

     }


   return(true);

  }



//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool Buy(string symbol ,int MagicIndex, double Lots, int StopLossMethod, double StopLossPoints, int TakeProfitMethod, double TakeProfitPoints, int Slippage, int MaxOpenTrades,

         int MaxFrequencyMins, string TradeComment)

  {

    int digits=(int)MarketInfo(symbol,MODE_DIGITS);

   double points=MarketInfo(symbol,MODE_POINT);

   double bid=MarketInfo(symbol,MODE_BID);

   double ask=MarketInfo(symbol,MODE_ASK);

   

   static double pipSize = 0;

   if(pipSize == 0)

      pipSize = points * (1 + 9 * (digits == 3 || digits == 5));


   double sl = 0, tp = 0;

   double stopLossPoints = 0, takeProfitPoints = 0;


   int numberOfOpenTrades = 0;


   for(int i=OrdersTotal()-1; i>=0; i--)

     {

      if(!OrderSelect(i, SELECT_BY_POS))

         continue;

      if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != symbol)

         continue;

      numberOfOpenTrades ++;

     }


   if(MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades)

      return(false);


   if(MaxFrequencyMins  > 0)

     {

      int recentSeconds = MaxFrequencyMins * 60;


      for(int i=OrdersTotal()-1; i>=0; i--)

        {

         if(!OrderSelect(i, SELECT_BY_POS))

            continue;

         if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() != symbol)

            continue;

         if(TimeCurrent() - OrderOpenTime() < recentSeconds)

            return(false);

        }


      int hstTotal=OrdersHistoryTotal();


      for(int i=hstTotal-1; i>=0; i--)

        {

         if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))

            continue;

         if(OrderMagicNumber() != __STRATEGY_MAGIC + MagicIndex || OrderSymbol() !=symbol)

            continue;

         if(TimeCurrent() - OrderOpenTime() < recentSeconds)

            return(false);

         break;

        }

     }


   if(Lots < MarketInfo(symbol,MODE_MINLOT))

      return(false);


   if(AccountFreeMarginCheck(symbol, OP_SELL,Lots) <= 0)

     {

      Print("Buy error: insufficient capital");

      return(false);

     }


   if(StopLossPoints > 0)

     {

      if(StopLossMethod == 0)

        {

         sl = NormalizeDouble(ask - StopLossPoints * points, digits);

         stopLossPoints = StopLossPoints;

        }

      else

         if(StopLossMethod == 1)

           {

            sl = NormalizeDouble(ask - StopLossPoints * pipSize, digits);

            stopLossPoints = StopLossPoints * (1 + 9 * (digits == 3 || digits == 5));

           }

         else

           {

            sl  = StopLossPoints;

            stopLossPoints = (ask - sl)/Point;

           }

     }


   if(TakeProfitPoints > 0)

     {

      if(TakeProfitMethod == 0)

        {

         tp = NormalizeDouble(ask + TakeProfitPoints * points, digits);

         takeProfitPoints = TakeProfitPoints;

        }

      else

         if(TakeProfitMethod == 1)

           {

            tp = NormalizeDouble(ask + TakeProfitPoints * pipSize, digits);

            takeProfitPoints = TakeProfitPoints * (1 + 9 * (digits == 3 || digits == 5));

           }

         else

           {

            tp = TakeProfitPoints;

            takeProfitPoints = (tp - ask)/Point;

           }

     }


   double stopLevel = MarketInfo(symbol,MODE_STOPLEVEL) + MarketInfo(symbol,MODE_SPREAD);


   if((sl > 0 && stopLossPoints <= stopLevel) || (tp > 0 && takeProfitPoints <= stopLevel))

     {

      Print("Cannot Buy: Stop loss and take profit must be at least "

            + DoubleToStr(MarketInfo(symbol,MODE_STOPLEVEL) + MarketInfo(symbol,MODE_SPREAD),0)

            + " points away from the current price");

      return (false);

     }


   RefreshRates();

   int result = OrderSend(symbol, OP_BUY, Lots, ask, Slippage, sl, tp, "FxProQuant" + "(" + WindowExpertName() + ") " + TradeComment, __STRATEGY_MAGIC + MagicIndex);


   if(result == -1)

     {

      Print("Failed to Buy: " + IntegerToString(GetLastError()));

      Sleep(__SLEEP_AFTER_EXECUTION_FAIL);

      return(false);

     }


   return(true);

  }


//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool ReadCSVFile()

  {

   if(!FileIsExist(_FileName))

      return false ;


   int handle=FileOpen(_FileName,FILE_CSV|FILE_READ,";") ;

   int line=0;

   if(handle!=INVALID_HANDLE)

     {

      while(!FileIsEnding(handle))

        {

         ArrayResize(inputs,line+1);

         inputs[line]._Currency=FileReadString(handle);

         inputs[line]._TimeFrame=FileReadString(handle);

         inputs[line]._Slowing=FileReadString(handle);

         inputs[line]._Whole_Number_Input=FileReadString(handle);

         inputs[line]._Grid_Points=FileReadString(handle);

         inputs[line]._SL_Percentage=FileReadString(handle);

         inputs[line]._RSI_Buy_Limit=FileReadString(handle);

         inputs[line]._Sell_TP_in_Points=FileReadString(handle);

         inputs[line]._Max_Days=FileReadString(handle);

         inputs[line]._Stoc_Buy_Limit=FileReadString(handle);

         inputs[line]._Mom_Buy_Limit=FileReadString(handle);

         inputs[line]._D_Period=FileReadString(handle);

         inputs[line]._Stoc_Sell_Limit=FileReadString(handle);

         inputs[line]._RSI_Sell_Limit=FileReadString(handle); ;

         inputs[line]._Mom_Sell_Limit=FileReadString(handle);

         inputs[line]._Buy_TP_in_Points=FileReadString(handle);

         inputs[line]._Max_Open_Trades=FileReadString(handle);

         inputs[line]._Lot_Percentage=FileReadString(handle);

         line++ ;

        }

      FileClose(handle);

     }

   else

     {

      return false ;

     }


   ArrayResize(inputsAct,ArraySize(inputs)-1);

   for(int i=0; i<ArraySize(inputsAct); i++)

     {

      inputsAct[i]._Currency=inputs[i+1]._Currency;

      inputsAct[i]._TimeFrame=inputs[i+1]._TimeFrame;

      inputsAct[i]._Slowing=(int)inputs[i+1]._Slowing;

      inputsAct[i]._Whole_Number_Input=(int)inputs[i+1]._Whole_Number_Input;

      inputsAct[i]._Grid_Points=(int)inputs[i+1]._Grid_Points;

      inputsAct[i]._SL_Percentage=StringToDouble(inputs[i+1]._SL_Percentage);

      inputsAct[i]._RSI_Buy_Limit=(int)inputs[i+1]._RSI_Buy_Limit;

      inputsAct[i]._Sell_TP_in_Points=(int)inputs[i+1]._Sell_TP_in_Points;

      inputsAct[i]._Max_Days=(int)inputs[i+1]._Max_Days;

      inputsAct[i]._Stoc_Buy_Limit=(int)inputs[i+1]._Stoc_Buy_Limit;

      inputsAct[i]._Mom_Buy_Limit=StringToDouble(inputs[i+1]._Mom_Buy_Limit);

      inputsAct[i]._D_Period=(int)inputs[i+1]._D_Period;

      inputsAct[i]._Stoc_Sell_Limit=(int)inputs[i+1]._Stoc_Sell_Limit;

      inputsAct[i]._RSI_Sell_Limit=(int)inputs[i+1]._RSI_Sell_Limit;

      inputsAct[i]._Mom_Sell_Limit=StringToDouble(inputs[i+1]._Mom_Sell_Limit);

      inputsAct[i]._Buy_TP_in_Points=(int)inputs[i+1]._Buy_TP_in_Points;

      inputsAct[i]._Max_Open_Trades=(int)inputs[i+1]._Max_Open_Trades;

      inputsAct[i]._Lot_Percentage=StringToDouble(inputs[i+1]._Lot_Percentage) ;

     }

   return true ;

  }


//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int StringToTimeFrame(string tf)

  {

   if(tf=="M1")

      return PERIOD_M1 ;

   else

      if(tf=="M5")

         return PERIOD_M5 ;

      else

         if(tf=="M15")

            return PERIOD_M15 ;

         else

            if(tf=="M30")

               return PERIOD_M30 ;

            else

               if(tf=="H1")

                  return PERIOD_H1 ;

               else

                  if(tf=="H4")

                     return PERIOD_H4 ;

                  else

                     if(tf=="D1")

                        return PERIOD_D1 ;

                     else

                        if(tf=="W1")

                           return PERIOD_W1 ;

                        else

                           if(tf=="MN1")

                              return PERIOD_MN1 ;


   return PERIOD_CURRENT ;

  }



//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

void SetSettings(string symbol)

  {

   bool found=false ;

   for(int i=0; i<ArraySize(inputsAct); i++)

     {

      if(inputsAct[i]._Currency==symbol)

        {

         _Currency=inputsAct[i]._Currency ;

         _TimeFrame=StringToTimeFrame(inputsAct[i]._TimeFrame);

         _Slowing = inputsAct[i]._Slowing;

         _Whole_Number_Input = inputsAct[i]._Whole_Number_Input;

         _Grid_Points = inputsAct[i]._Grid_Points;

         _SL_Percentage = inputsAct[i]._SL_Percentage;

         _RSI_Buy_Limit = inputsAct[i]._RSI_Buy_Limit;

         _Sell_TP_in_Points = inputsAct[i]._Sell_TP_in_Points;

         _Max_Days = inputsAct[i]._Max_Days;

         _Stoc_Buy_Limit = inputsAct[i]._Stoc_Buy_Limit;

         _Mom_Buy_Limit = inputsAct[i]._Mom_Buy_Limit;

         _D_Period = inputsAct[i]._D_Period;

         _Stoc_Sell_Limit = inputsAct[i]._Stoc_Sell_Limit;

         _RSI_Sell_Limit = inputsAct[i]._RSI_Sell_Limit;

         _Mom_Sell_Limit = inputsAct[i]._Mom_Sell_Limit;

         _Buy_TP_in_Points = inputsAct[i]._Buy_TP_in_Points;

         _Max_Open_Trades = inputsAct[i]._Max_Open_Trades;

         _Lot_Percentage =inputsAct[i]._Lot_Percentage;

         found=true ;

         break ;

        }

      else

        {

         continue ;

        }

     }


   if(!found)

     {

      _Currency=symbol;

      _TimeFrame=PERIOD_CURRENT ; // Trading TimeFrame

      _Slowing = 3;       // Slowing

      _Whole_Number_Input = 10;       // Period

      _Grid_Points = 200;       // Grid Points

      _SL_Percentage = 1;       // SL Percentage

      _RSI_Buy_Limit = 25;         // RSI Buy Limit

      _Sell_TP_in_Points = 300;       // Sell TP in Points

      _Max_Days = 14;        // Max Days

      _Stoc_Buy_Limit = 15;        // Stoc Buy Limit

      _Mom_Buy_Limit = 99.5;       // Mom Buy Limit

      _D_Period = 3;         // D Period

      _Stoc_Sell_Limit = 85;       // Stoc Sell Limit

      _RSI_Sell_Limit = 75;        // RSI Sell Limit

      _Mom_Sell_Limit = 100.5;        // Mom Sell Limit

      _Buy_TP_in_Points = 300;        // Buy TP in Points

      _Max_Open_Trades = 6;        // Max Open Trades

      _Lot_Percentage = 0.5;       // Lot Percentage

     }

  }


//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int GetGlobalOrders()

  {

   int cnt=0 ;

   for(int i=0; i<OrdersTotal(); i++)

     {

      if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==__STRATEGY_MAGIC+1)

         cnt ++;

     }

   return cnt ;

  }

//+------------------------------------------------------------------+


附加的文件:

反馈

1
开发者 1
等级
(38)
项目
50
10%
仲裁
1
0% / 0%
逾期
8
16%
空闲
2
开发者 2
等级
项目
2
0%
仲裁
3
67% / 33%
逾期
0
空闲
相似订单
Hello I'm in possesion of a straightforward MT% Expert AdvisorThat I want to convert into DXTrade. Are you able to do this conversion? Kindly let me know if the fil atached will be enough
Hello, I need a quote for developing a bot for my renko based trading system on ctrader platform and based on the attached specification your expertise is highly needed for this project Thanks
Hi Friends, we are forex broker ,we have MT5 admin , manager , and access everything, and we need personal trade copier ,with more options included. And below requirements are compulsory enable in copier, #1 If i delete (disappear) one open position in master account, then also delete (disappear) all slave accounts in same open position, in B Book (NO LP ) accounts. #2. I want
Fix my ea and add reverse trade feature plus has Make ea with trailing stop, once trade is closed in loss open in opposite, close in win open in same position. The ea must trail from 0 ( from the start)
Hello, please let me know if any of these strategies can be turned into a bot (automation) and run 24/7 on a vps. Also note that they might not use the latest versions of indicators, if this matters, then please check for the latest versions. Thank you! Dan https://1drv.ms/f/s!Alr17W7ddJLYgYgiFKZYluOfokbfQg
Hello! Thanks for reading. I need an EA with an inbuilt/already made strategy that I can use for prop firms. The drawdown should be very low of only 2-4% max and another criteria is that no one else other than you are currently using it and if you happen to use it you must tell me which prop firm you are using it on to avoid us using the same EA on the same prop firm to get the account denied. As you know or may
Hello, I am looking for an programmer to convert a TradingView strategy pine script to MT5 EA auto trade bot. The indicator is based on the FVG/Imbalance (Pine script will be provided) The MT5 EA must return 100% the same results as TradingView script The MT5 EA must include the same options as TradingView The MT5 EA must be errors free
I need to convert two mt4 indicators into Quantower. The two simple mt4 indicators are Hieken Ashi and Price Channel Signal. I want to integrate these two indicators into Quantower platform
Hi, Would it be possible to get a developer for my trading system based on the attached specification? EA DETAILS Indicators to use (1) Better RSI () (2) Dynamic Linear Regression Channel (DLRC) by Iravan on Tradingview.com () (3) Range filter Buy and Sell 5 min – guikroth version on Tradingview.com () (With Dynamic Linear Regression, the period/length is automatically adjusted making it much faster to trade
Hello I am looking for a developer to help me backtest my custom ninjatrader 8 strategy andake it work perfectly your expertise is highly need for this project kindly reach out to me and let proceed

项目信息

预算
120 - 160 USD
开发人员
108 - 144 USD
截止日期
 5  10 天