Convert a MT4 EA to a cTrader cBot

Termos de Referência

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 ;

  }

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


Arquivos anexados:

Respondido

1
Desenvolvedor 1
Classificação
(38)
Projetos
50
10%
Arbitragem
1
0% / 0%
Expirado
8
16%
Livre
2
Desenvolvedor 2
Classificação
Projetos
2
0%
Arbitragem
3
67% / 33%
Expirado
0
Livre
Pedidos semelhantes
preciso de um robô com duas médias móveis, uma exponencial high e uma exponencial low. preciso também ter a opção de utilizar e todos os tempos gráficos e alterar os parâmetros das médias. entrada de compra será feita quando um candle de alta romper e fechar a cima da média high e fechará a posição quando um candle de baixa romper e fechar a baixo da média low. a venda será feita quando o candle de baixa romper e
I need a chart to replicate/track my equity + Balance Curve into my mt4. Also this chart i need to be able to add Stochastic / Bollingerband / Moving average on the equity/balance curve. Besides the equity curve i would like the indicator to show the Line-chart of my win + 1 and my loss -1 which results in a win-loss curve. ( i will discuss this with the choosen developer in depth. ) More information on what i want
Greetings great developer, I am in search of a highly skilled developer to assist with an exciting project. I need to convert two open-source TradingView indicators to NinjaTrader 8 and implement a usage restriction based on computer IDs. If you have experience with NinjaTrader 8 coding please let me know. I’d be happy to discuss the details further
Greetings great developer, I am in search of a highly skilled MQL5 developer to assist with an exciting project. I need to convert two open-source TradingView indicators to NinjaTrader 8 and implement a usage restriction based on computer IDs. If you have experience with NinjaTrader 8 coding please let me know. I’d be happy to discuss the details further
Trading bot 300+ USD
We need bot that trades when medium and low impact news hits It will release pending order both directions few min prior to news impact And will have certain risk management strategy attached Example If Monday and Tuesday news successful clears profits It will reduce risk for next news events until new week starts each week message on tg: Dstatewealthtrading NOTE: 4 YAERS OF EXPERIENCE UPWORD, YOU MUST BE A
I need someone the create a supertrend indicator based on Heikin Ashi candles instead of normal candles. Needs to be exactly the same as the supertrend (original one) + ha from tradingview. In m1,m5,m15 the indicator must have the same values ​​found with the tradingview. Work that meets this requirement will be accepted ( depending on the broker and spread, however, a few pips of difference will be accepted)
Here is a detailed instruction for the coder to implement the vertical lines based on the BrainTrainSignalAlert indicator: --- **Task: Implement Vertical Lines for Alerts from BrainTrainSignalAlert Indicator** **Objective:** Create a system that adds vertical lines on specified timeframes (M5 or M30) whenever an alert is generated by the BrainTrainSignalAlert indicator on the H1, H4, and D1 timeframes. The lines
are you aware of the Monday Range Strategy? https://www.youtube.com/watch?v=7B_yBBFx6z8 5pm EST time sunday - monday 5pm est and it has to be on the H1 chart , minimum 1:2 Risk to reward and break even function after 1:1
Hello, I need someone who have a great experience in ATAS platforms, I use ATAS software for orderflow and i would like tradingview to draw some light information from ATAS to tradingview. If you are capable of this please send me a message and let's proceed
### Summary of EA Requirements 1. **Time Period**: - The EA should operate on the H4 timeframe. 2. **RelicusRoad MACD v2 Indicator**: - **Parameters**: - Fast EMA Period: 12 - Fast EMA Type: Close price - Slow EMA Period: 24 - Slow EMA Type: Close price - Signal SMA Period: 9 - The EA should use this indicator to determine the crossover condition between the MACD line and the signal line. 3

Informações sobre o projeto

Orçamento
120 - 160 USD
Desenvolvedor
108 - 144 USD
Prazo
de 5 para 10 dias