Page 1 of 1

Coding Martingale strategy need help delphy

Posted: Mon May 08, 2017 6:37 am
by zeeshan
hi,
i am trying to code in delphi martingale strategy its simple
1) take an order when strategy starts with Buy order, with a variable TP
2) if the price moves X amount of pips down take another order, and so on
3) As the additional orders are taken adjust TP of all the orders to average gain so far the problem is that second order is not being taken :

Code: Select all

begin
   if Symbol <> Currency then
   exit;
   if OrdersTotal = 0  then
      SendInstantOrder(Symbol, op_Buy, LotSize, Ask - 1000*Point , Ask + TakeProfit*Point, '', 0, OrderHandle);

   for i := 1 to MaxLots do
      begin
        OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
        if (OrdersTotal = i) and (OrderProfitPips < -ReEntry*i) then
          SendInstantOrder(Symbol, op_Buy, LotSize+(LotBoast*i*0.1), Ask - 1000*Point , Ask + TakeProfit*Point, '', 0, OrderHand);
      end;


end;


kindly check why second order is not being executed.