Has anyone had this problem?
I have a function which I call from an indicator which has a length as one of the parameters. My main indicator allows this to be turned off so I check for the length being zero to skip the function call eg:
if SmoothLength > 0 then
Ind2 = MySmooth(Ind, SmoothLength)
else
Ind2 = Ind;
However, this doesn't seem to work as the indicator crashes with a divide by zero error when the length is zero. The function does do a divide by the length as one of the calculations. If I comment this call out it's fine.
The way around this is to have 2 seperate functions but it's a pain to do this everytime I want optional parameters like this.
Any ideas?
Thanks
Problem skipping function call in indicator
- ABC
- Posts: 718
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 408 times
- Contact:
sparkz,
if I understand you correctly, the problem lies inside the function which does divide one value through the Length.
Adding:
to function should stop the divide by zero error.
Regards,
Chris
if I understand you correctly, the problem lies inside the function which does divide one value through the Length.
Adding:
Code: Select all
If Length <> 0 then YourParameter/Length
Regards,
Chris