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