How to eliminate error messages in the Expert Advisor
I have a 200-day EMA commentary in the Expert Advisor. The security that I loaded contains less than 200 bars of data. It results in this error message: *Error* Function did not return a value. How do I eliminate this error message?
writeif(lastvalue(cum(1))>200,"The 200 day EMA is at writeval(mov(c,200,e))","")
The code uses the writeif() function to check the condition of lastvalue(cum(1))>200 which counts the number of bars in the open chart. If the last value of this is greater than 200 then there must be more than 200 bars of data in the chart. This makes the expression TRUE and the statement is printed to the screen with the value of the 200 day EMA. If there is less than 200 bars in the chart the output is nothing.
Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.