Hi
My system is stopping every Sunday night at 2305 without fail. It works the rest of the week. The reason if gives me is more or less a divide by zero error. I believe the reason is because there is not sufficent data (previous bars) in order for me to make the required calculation.
The code I am using is along the lines of
Gap = Close-CustomClose[1]
IF <indicator> and GAP <= 21 THEN
Etc etc
I believe at certain times Gap is not able to return a value so the system fails. Is there a way to code around this? something along the lines of:
If Gap = Null/Error then do nothing Else carry on etc?
Hope this makes sense as I kind of new to ccoding.
thanks!
Try …
Gap = max(1, Close-CustomClose[1])
You can try this to make sure it’s never 0:
Gap = Close-CustomClose[1]) + 0.000001
this small amount shouldn’t affect your performance (but you can increase or decrease it).
You can also write it as:
Gap = Close-CustomClose[1]
IF Gap = 0 THEN
Gap = 0.000001
ENDIF
@GraHal
that works with positive numbers, but in this case the gap can be negative and your code could change it quite a bit!
Doh!, yes, that seems so intuitive and obvious (now I see it!).
Thank you so very much, I will try these out.
now I see it!).
Must have been that monobrow obstructing your vision! 🙂 (sorry couldn’t resist! 🙂 )
now I see it!).
Must have been that monobrow obstructing your vision! 🙂 (sorry couldn’t resist! 🙂 )
Haha, I guess i deserved that! 😬