Help Needed!! Parameter not updated

 
if(MathAbs(psprd) >= FF* stddev && MathAbs(sprd)<= FF* stddev) {
for(i=0; i<pairs; i++){
if(sprd< 0) units = MathRound(base_units * coef[i]);
if(sprd> 0) units = MathRound(-base_units * coef[i]);

if(OrdersTotal() != 0 && units * GlobalVariableGet(GLOBALNAME+Symbol()+Period()+"_"+symb[i])< 0) {
tradeCount = 0;
CloseOrder(symb[i], units);
GlobalVariableSet(GLOBALNAME+Symbol()+Period()+"_"+symb[i], 0);
continue;
}
if(OrdersTotal() < pairs) {
tradeCount = 1;
CreateOrder(symb[i], units);
GlobalVariableSet(GLOBALNAME+Symbol()+Period()+"_"+symb[i], units);
}
}//for(i=0; i<pairs; i++)

Print("tradeCount ",tradeCount);

Code as above, I managed to close trade, however how come my tradeCount always = 1?

 

Hmm I wonder too :-D

*edit - what is the value of pairs?

if(OrdersTotal() < pairs) {
tradeCount = 1;
 

Going forward use SRC feature to post code. Use print statement inside if loop. Use like below:


      if(OrdersTotal() != 0 && units * GlobalVariableGet(GLOBALNAME+Symbol()+Period()+"_"+symb[i])< 0) 
      {
         tradeCount = 0;
         CloseOrder(symb[i], units);
         GlobalVariableSet(GLOBALNAME+Symbol()+Period()+"_"+symb[i], 0);
         Print("Inside first IF. tradeCount: ",tradeCount);
         continue;
      }
      if(OrdersTotal() < pairs) 
      {
         tradeCount = 1;
         CreateOrder(symb[i], units);
         GlobalVariableSet(GLOBALNAME+Symbol()+Period()+"_"+symb[i], units);
         Print("Inside second IF. tradeCount: ",tradeCount);
      }
 

pairs = 2

thanks for the comment guys!!

 
ShinjiOno:

Code as above, I managed to close trade, however how come my tradeCount always = 1?


Is this . . . .

units * GlobalVariableGet(GLOBALNAME+Symbol()+Period()+"_"+symb[i])

. . ever negative ?

Reason: