Coding Martingale strategy need help delphy

Examples step by step how to make your own automated strategy or user indicator
Message
Author
zeeshan
Posts: 3
Joined: Wed Mar 12, 2014 12:28 pm

Coding Martingale strategy need help delphy

#1 Postby zeeshan » Mon May 08, 2017 6:37 am

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.

Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 2 guests