Discussions
»
Special Interest Groups
»
Advanced Coding Techniques
»
BarsSince, ValueWhen and Custom Formula call in an Expert.
Rank: Newbie
Groups: Registered, Registered Users Joined: 3/19/2006(UTC) Posts: 8 Location: Analyst
|
Good day all,
I have an issue with the above functions working together. I have a custom formula that determines if a trend exists or not. If not the formula equals 5. I can accurately determine how long the market has been flat (e.g 9 days) using BarsSince() but when I try to ascertain the closing price when no trend existed, using ValueWhen, it fails to give the correct value. And if I 'page' back in time in the Expert, the length of time the market was flat decreases accordingly but the closing price changes each time. Perhaps I have gone 'code' blind and someone can easily see the errors of my ways. If so let me know. Or perhas there is a better way to achieve my goals.
In the Expert I have;
writeif( Fml( "MT-Trend") = 5, "<Name> is not trending over the medium term it is flat. It has been flat for the past writeval( BarsSince( Fml( "MT-Trend") <> 5 ),0.0) day(s). The closing price at that time was writeval(valuewhen(1, BarsSince( Fml( "MT-Trend") <> 5 ),c),3.4)", ")
Thank you in advance.
Steve
|
|
|
|
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)
|
Hi Steve, Try this: Code:writeval(
valuewhen(1, Fml("MT-Trend") <> 5 ), c)
,3.4)
Note: the BarsSince() was the part that was causing the (logic) error and has been removed. Hope this helps. wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 3/19/2006(UTC) Posts: 8 Location: Analyst
|
Thanks for spotting my error wabbit. [:$]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Special Interest Groups
»
Advanced Coding Techniques
»
BarsSince, ValueWhen and Custom Formula call in an Expert.
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.