Discussions
»
Product and Service Development
»
MetaStock
»
Eliminate Error Message in Expert Advisor [RESOLVED]
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/12/2005(UTC) Posts: 2
|
I would like to eliminate those error message in my Expert Advisor Commentary. Is there a way to do it, I tried a few methods, but it failed.
For example, I have added in a 200-days EMA commentary in the Expert Advisor Commentary. The security that I loaded is less than 200 bars of data. It comes out with an error message (*Error* Function did not return a value), how do I eliminate this error message?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
One way is to use something along the lines of:
writeif(lastvalue(cum(1))>200,"The 200 day EMA is at writeval(mov(c,200,e))","")
Hope this helps.
wabbit :D
[edited bit]
Actually you dont need the last set of quotes (the return if false part) but I include them anyway, it helps the readability as I already have in my mind that for every IF statement there is going to be a TRUE and FALSE return.
If you are struggling for space in your commentary, use the abbreviated form:
writeif(lastvalue(cum(1))>200,"200 EMA: writeval(mov(c,200,e))")
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Sorry, I should also have explained the code...
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.
Hope that makes sense.
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Patrick,
This is another one of those occassions where the logic in MS has me perplexed.
We should be able to do something along the lines of:
writeif(isdefined(mov(c,200,e)),"The 200 day EMA is at writeval(mov(c,20,e))","")
without generating errors, but it does generate errors due that awry logic discussed already on other forum threads.
Any chance of reviewing this one in future versions?
wabbit :D
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
MetaStock
»
Eliminate Error Message in Expert Advisor [RESOLVED]
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.