Convert a MT4 EA to a cTrader cBot

Specification

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 ;

  }

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


Files:

Responded

1
Developer 1
Rating
(38)
Projects
50
10%
Arbitration
1
0% / 0%
Overdue
8
16%
Free
2
Developer 2
Rating
Projects
2
0%
Arbitration
3
67% / 33%
Overdue
0
Free
Similar orders
Hi, i have a simple strategy which has 4 different types of entries based on parabolic sar and moving average that I would like to be coded into an EA. I would also like some inputs for it like news filter, time start and time end, risk % and so on. Will discuss further upon application
I want a developer who can develop an EA that enter a trade that is opposite of what 15m Candles does(example: if the 15m Candlestick is buying you put selling order and when is selling it place buying orders) 10 Seconds before 3 Bulls Major News and Nasdaq Open and once it has triggered it enter 1 trade whenever each position has moved 10 points and it does so continually until it has entered 10 position and
Hey there, I need to convert an indicator from ninja to mt4 I will attach the ninjatrader indicator script to be converted into mt4 If you can do this kindly bid and let's discuss about the project Thanks
I need to combine 3 indicators into one. With all settings as in the original indicators. The modification of the indicator should consist in not showing all the signals on the chart from the indicators, but only one signal when all the indicators are consistent with the direction. Then one signal appears on the chart. The indicator will work on the traditional chart and on the offline chart (renko etc..) It is
Hi, I need to add a module to existing EA to enalbe it to buy and sell baskest of stocks and indicies. What I need: - synthetic chart in MT5 of e.g. combination of 2 long stocks and 5 shorted stocks. I need to be able to easily create new charts of the mixes of stocks / indicies. - matrix / panel of the chosen stocks' CFDs which tickers one will choose from the Symbol list (at particular broker symbol list) - adding
I have already develop metatrader 4 indicator that is exhibiting some error which in turn making the indicator to misbehave so what i need right now is to correct the error, if you are very good in mql4 language, please bid and figure out this can be solve and make it works the way i want it to work
Please I need a profitable EA with any of the following criteria; Hedge Trading Hedging trades is permitted however, hedging separate accounts against each other (known as Wash Trading) is not permitted and is a direct violation of the OnlyFunds’ Terms and Conditions. Wash trading is illegal and considered to be fraudulent, as it undermines the integrity of financial markets. Swing Trading Swing trading is
Looking for a developer of profitable EA tested for over 2 or more years time history of profits with investors read me only access as proof of usage. MT4 or MT5
Adjust MY Hedging EA 30 - 40 USD
1. Need averaging TP for my hedging EA. (Close both Buy and Sell position with TP) 2. Add function auto/manual entry. (EA will entry based on manual position(placed by trader) or auto trade based on existing setting)
I am in search of a skilled robot developer to craft a Martingale with Hedge strategy algorithm. The ideal candidate will possess deep expertise in algorithmic trading, proficiency in programming languages, and a keen understanding of financial markets. The role entails designing and implementing an automated system capable of effectively executing the Martingale strategy while integrating a hedge mechanism to manage

Project information

Budget
120 - 160 USD
For the developer
108 - 144 USD
Deadline
from 5 to 10 day(s)