how to increment tp 3 level every lot

 

hello every one...

i have problem in that..

i can increment lots and profit when get sl,

if got tp, so will return to beginning..

but i can not combined them..

this is my code:

void CheckIfOrderEarned()
   {
   
   int i=OrdersHistoryTotal()-1;
   //----
   OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      {                                     
      OT = OrderType();
      OL = OrderLots();
      SL = OrderStopLoss();
      TP = OrderTakeProfit();
      _symbol = OrderSymbol();
      double OP = OrderProfit();
       double OOP = OrderOpenPrice();

      
      if (OrderMagicNumber() == Magic)
         {
     
   

     if (OrderProfit() <0 && OrderLots() < NormalizeDouble(templots*3,2))
     {
   
     if (OrderLots()==Lots && MathAbs((TP-OOP)/Point) <= TempProfit*3 )
     {
    
          TakeProfit = MathAbs((TP-OOP)/Point)+TempProfit;
       
         }    
         
               
    }
          

else 
            {
          //  TakeProfit= 20;
            Lots = templots;
            TakeProfit = TempProfit;
            }
             
                           
         }
      }
   }

i want condition like this:

1 first open using lot 0.1 and tp 20 pips, get sl..

2. open second still using lot 0.1, but tp increase be 40, get sl..

3. open third still using lot 0.1, tp be 60, get sl.

4. because have 3 times get sl, so the next open using lot 0.2, tp be 20...

5.........


i can increase lot double every get sl, and profit double every get sl..

but i can not make every lot have 3 level tp incerement..

because that code i make, that result increase lot and tp together when get sl..


what should i change the code?

thx..
 
helpp...
 

you have to introduce a counter where you log how many trades you have opened.

and when

if(counter%3==0)

increase your lots.

 

thx zuegg,

are u mean counter= TakeProfit?

if TakeProfit /3=0, so increase lots..

i have add your code, and my code be like this:

if (OrderProfit() <0 && MathAbs((TP-OOP)/Point) <= TempProfit*3 )
   {
   TakeProfit = MathAbs((TP-OOP)/Point)+TempProfit;
   }
if( TakeProfit % (TempProfit*3)==1)
                {
         
                   Lots = NormalizeDouble(OL*2, 2); 
                }

but that % is error %' - remainder operator is to be applied to integer values only

how to fix that interger?

is the "%" same with "/" or ":" means divided?