Using Multiplier to get profit

 

Hello All,

I am trying to write a simple EA wherein the trade is picked based on the moving averages. However, if the trade goes beyong a certain loss (consider 100 pips) then it should pick the next lot size (for example the previous lot size X 2).  I have written the code since I am using multiple symbols at the same time on a single chart window.


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

      {

      

         int aku=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

         double TP = NormalizeDouble(TakeProfit*(double)MarketInfo(OrderSymbol(), MODE_POINT)*10,(int)MarketInfo(OrderSymbol(), MODE_DIGITS));



         if(OrderLots()==MathPow(2,TotalSingleOrder(OrderSymbol(), OrderType())-1)*LotSize)

         {

         



            if(OrderType()==OP_BUY)

               if((double)MarketInfo(OrderSymbol(),MODE_ASK)<OrderOpenPrice()-TP)

                  if(OrderLots()<=MaxLotSize*2)

                  {

                     TP = NormalizeDouble(TakeProfit*(double)MarketInfo(OrderSymbol(), MODE_POINT)*10,(int)MarketInfo(OrderSymbol(), MODE_DIGITS));

                     aku = OrderSend(OrderSymbol(), OP_BUY, OrderLots()*2, (double)MarketInfo(TradeSymbol, MODE_BID), 10, 0, (double)MarketInfo(TradeSymbol, MODE_ASK)+TP, "NeoLogic",22349,0,clrNONE);

                     ModifyOrder(OrderSymbol(), OrderType(), TP);

                  }



            if(OrderType()==OP_SELL)

               if((double)MarketInfo(OrderSymbol(), MODE_BID)>OrderOpenPrice()+TP)

                  if(OrderLots()<=MaxLotSize*2)

                  {

                     TP = NormalizeDouble(TakeProfit*(double)MarketInfo(OrderSymbol(), MODE_POINT)*10,(int)MarketInfo(OrderSymbol(), MODE_DIGITS));

                     aku = OrderSend(TradeSymbol, OP_SELL, OrderLots()*2, (double)MarketInfo(TradeSymbol, MODE_ASK), 10, 0, (double)MarketInfo(TradeSymbol, MODE_BID)+TP, "NeoLogic",22349,0,clrNONE);

                     ModifyOrder(OrderSymbol(), OrderType(), TP);

                  }

            

            

            

            

         }

      }
 
Amar K Uttarkar: However, if the trade goes beyong a certain loss then it should pick the next lot size (for example the previous lot size X 2).  I

Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
          Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum (2015)

Why it won't work:
          Calculate Loss from Lot Pips - MQL5 programming forum (2017)
          THIS Trading Strategy is a LIE... I took 100,000 TRADES with the Martingale Strategy - YouTube (2020)

 
William Roeder #:

Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
          Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum (2015)

Why it won't work:
          Calculate Loss from Lot Pips - MQL5 programming forum (2017)
          THIS Trading Strategy is a LIE... I took 100,000 TRADES with the Martingale Strategy - YouTube (2020)

Resolved. Thanks!