If I change it back again to DMultiple4, DMultiple4 is 0.00000000. Why is this happening? I have no explanation.
Ok, so I tried a little experiment. I had the variable named DMultiple4. and the Divide by Zero error was there.
So without changing anything else, I saved another copy of my EA with a slightly different name. I compiled the new saved copy and tried it. No divide by zero! Does the compiler use cached data of any kind?
Hi WHRoeder!
I have the variable declared as an external in the global scope. The notes in the code that I posted aren't really in the program. I just wanted to show how it was being declared on the global scope. It's not actually re-declared locally in the function. Here's the entire function:
// --------------------------- // double GetSigData(int SignalID, int TimeofP) { double data, D; if(TimeofP == 0){TimeofP = 1;} if(SignalID == 0) { D = iRSI(NULL,SubTime,RSIPeriod,RSIApplied,TimeofP); data = MathRound(D/DMultiple0)*DMultiple0; } if(SignalID == 1) { D = iDeMarker(NULL,SubTime,DEMPeriod,TimeofP)*100; data = MathRound(D/DMultiple1)*DMultiple1; } if(SignalID == 2) { D = iStdDev(NULL,SubTime,STDPeriod,0,1,4,TimeofP); data = MathRound(D/DMultiple2)*DMultiple2; } if(SignalID == 3) { D = iCCI(NULL,SubTime,CCIPeriod,CCIApplied,TimeofP); data = MathRound(D/DMultiple3)*DMultiple3; } if(SignalID == 4) { RefreshRates(); D = ((Ask-Bid)*100000); Print("DMultiple4 is "+DMultiple4); data = MathRound(D/DMultiple4)*DMultiple4; } if(SignalID == 5) { D = Volume[TimeofP]; data = MathRound(D/DMultiple5)*DMultiple5; } return(data); }
Also, The other DMultiple# variables didn't have this issue.
//+------------------------------------------------------------------+ //| Variable Declaration //+------------------------------------------------------------------+ // External Variables extern int Lean = 25; extern int MaxSpread = 20; extern double DMultiple0 = 1; extern int RSIPeriod = 14; extern int RSIApplied = 4; extern double DMultiple1 = 1; extern int DEMPeriod = 14; extern double DMultiple2 = 0.002; extern int STDPeriod = 89; extern double DMultiple3 = 1; extern int CCIPeriod = 14; extern int CCIApplied = 4; extern double DMultiple4 = 2; // This one is spread (in Points). extern double DMultiple5 = 500; // Signal5 is Volume[TimeofP].
Here are all the external declarations.
Here are all the external declarations.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I ran into something of a bug while writing some code to round spread data to the nearest multiple of my choice. See below:
Nowhere else in the code have I manipulated the variable DMultiple4. These are the only references to DMultiple4. The print returns that DMultiple4 is 0.00000000!
So I change the name of the variable to "Something". And it works without a problem. I even made the replacement using the "Replace all" command. The print will return Something is 2.00000000.
If I change it back again to DMultiple4, DMultiple4 is 0.00000000. Why is this happening? I have no explanation.