zero devide in live trading on all pair but not on gbp/usd

 

hi @ all


Zero devide occurs in live trading on all pair but not on gbp/usd, and not on demo on all pairs.



has anybody an idea?



thanks in advance

 

Show your code.

You have to find a division x/y where y == 0.

 
hey phy thanks for fast reply, here´s the code. it´s very long and has a few parts which are not needed, i know about, but until now i had no problem with it
 

Here are all the lines with divisions:

$ grep -E "/" y.mq4 | grep -Ev "//"
   lot=NormalizeDouble(AccountBalance()/10000/10,lotPrecision)*MaximumRisk;
   if(MicroAccount)lot=NormalizeDouble(lot/10/10,lotPrecision);
ProfitTarget=(iATR(NULL,240,750,1)+iATR(NULL,60,750,1))/Point/1.75/10;
  if(MaxProfit>ProfitTarget)SavedProfit=MaxProfit*((100-MaxRetrace)/100);else SavedProfit=-9999;
  if(MaxBuyProfit>ProfitTarget)SavedBuyProfit=MaxBuyProfit*((100-MaxRetrace)/100);else SavedBuyProfit=-9999;
  if(MaxSellProfit>ProfitTarget)SavedSellProfit=MaxSellProfit*((100-MaxRetrace)/100);else SavedSellProfit=-9999;
   if(BuyOrders>0)BreakEven=(SumBuy()/BuyLots/10000000);
   if(SellOrders>0)BreakEven=(SumSell()/SellLots/10000000);
RecActivation=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/3;
      double MaxLoss2 = AccountBalance()/100*MaxLossPercent2;
      double b=(iATR(Symbol(),PERIOD_H1,750,0))/Point;
      double a=(iATR(Symbol(),PERIOD_M15,750,0))/Point;
      double c=(b/a);
      double small=(b/c);
      double great=(b/e);
      double spacingmin = (a/1.25);
      double stddev1 = iStdDev(Symbol(),StDevTF,StDevPer,0,StDevMode,PRICE_OPEN,0)/Point;
      double stddev2 = iStdDev(Symbol(),StDevTF2,StDevPer2,0,StDevMode2,PRICE_OPEN,0)/Point;
      if ((iATR(Symbol(),15,3,0))/Point > acti || (iATR(Symbol(),15,3,1))/Point > acti ||
          (iATR(Symbol(),15,3,2))/Point > acti || (iATR(Symbol(),15,3,3))/Point > acti ||
          (iATR(Symbol(),15,3,4))/Point > acti || (iATR(Symbol(),15,3,5))/Point > acti) stddev3 = (iATR(Symbol(),15,3,0))*1.5/Point; else stddev3=0;
      if ((iATR(Symbol(),15,3,0))/Point > acti || (iATR(Symbol(),15,3,1))/Point > acti ||
          (iATR(Symbol(),15,3,2))/Point > acti || (iATR(Symbol(),15,3,3))/Point > acti ||
          (iATR(Symbol(),15,3,4))/Point > acti || (iATR(Symbol(),15,3,5))/Point > acti) stddev4 = (iATR(Symbol(),15,3,1))*1.5/Point; else stddev4=0;
      if ((iATR(Symbol(),15,3,0))/Point > acti2 || (iATR(Symbol(),15,3,1))/Point > acti2 ||
          (iATR(Symbol(),15,3,2))/Point > acti2 || (iATR(Symbol(),15,3,3))/Point > acti2 ||
          (iATR(Symbol(),15,3,4))/Point > acti2 || (iATR(Symbol(),15,3,5))/Point > acti2) stddev5 = (iATR(Symbol(),15,3,0))*2.25/Point; else stddev5=0;
      if ((iATR(Symbol(),15,3,0))/Point > acti2 || (iATR(Symbol(),15,3,1))/Point > acti2 ||
          (iATR(Symbol(),15,3,2))/Point > acti2 || (iATR(Symbol(),15,3,3))/Point > acti2 ||
          (iATR(Symbol(),15,3,4))/Point > acti2 || (iATR(Symbol(),15,3,5))/Point > acti2) stddev6 = (iATR(Symbol(),15,3,1))*2.25/Point; else stddev6=0;
      double recb=(iATR(Symbol(),15,3,1))*2.25/Point;
if(-BuyCycleProfit<=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/3||CycleProfit>0)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/3)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/1.5)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2*1.5)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2*2)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-BuyCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2*2.5)RecoveryTakeProfit=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(BuyCycleProfit<-1000.00||BuyCycleProfit>1000.00)cycleh=(CycleProfith+ProfitTarget)/1000;
if(BuyCycleProfit>-999.99&&BuyCycleProfit<999.99)cycleh=(CycleProfith+ProfitTarget)/100;
if(BuyCycleProfit>-99.99&&BuyCycleProfit<99.99)cycleh=(CycleProfith+ProfitTarget)/10;
AfterRecStartVolh=(CycleProfit1/RecoveryTakeProfit);
if(-SellCycleProfit<=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/3||CycleProfit>0)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/3)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/1.5)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2*1.5)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2*2)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
if(-SellCycleProfit>(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point*2*2.5)RecoveryTakeProfits=(iATR(NULL,240,50,1)+iATR(NULL,60,50,1))/Point/2;
AfterRecStartVolhs=(CycleProfit1s/RecoveryTakeProfits);
      MarginPercent = MathRound((AccountEquity() / AccountMargin()) * 100);
Start by debugging the lines that have a user variable or function in the divisor. There aren't many.
 

thanks phy,



but do you have an idea why the expert is working on demo on all pairs, but live it is writing zero devide?

 
Because something == 0 sometimes on live.
 

so i tried and found the problem, but now i don´t know how to solve it



if i change variable c for eg to 3 there is no zero devide,


double MaxLoss2 = AccountBalance()/100*MaxLossPercent2;
      double b=(iATR(Symbol(),PERIOD_H1,750,0))/Point;
      double a=(iATR(Symbol(),PERIOD_M15,750,0))/Point;
      double c=(3);


but changing var a or b doesn´´t help, do you have an idea why the ea can´t calculate var c?

double MaxLoss2 = AccountBalance()/100*MaxLossPercent2;
      double b=(iATR(Symbol(),PERIOD_H1,750,0))*Point;
      double a=(iATR(Symbol(),PERIOD_M15,750,0))*Point;			
      double c=(b/a);
 

If changing 'a' doesn't help, it can calculate 'c', and the value is zero.

Put in some Print statements to see what is going on.

 

yes phy c is zero, and this is caused thru iatr which returns zero!



But i think this is a very funny thing because the atr of 15min or 1hour is never zero.



any idea?

 

"But i think this is a very funny thing because the atr of 15min or 1hour is never zero."

You can debug your iATR problem, or set an arbitrary non-zero value when it returns zero.

 

what do u mean with "You can debug your iATR problem"?



I don´t understand what to do now?