Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am a total newbie, so I'll apologize now if my question or premise is completely naïve. I've looked everywhere I can and I simply can't find an answer to this question.
Using a "ShowMe" study, I'm trying to plot points on past bars based on current conditions. Below is a snippet of code simplifying the concept.....
variables: IntrabarPersist iIndexSaved(0);
if someSpecificCondition() then iIndexSaved = CurrentBar;
if someAnotherCondition() then Plot1[CurrentBar - iIndexSaved](High[CurrentBar - iIndexSaved);
Even though I never actually reference a bar less than my current data stream, this code seems to run until "CurrentBar - iIndexSaved" is greater than "MaxBarsBack", then "MaxBarsBack" is changed to "CurrentBar - iIndexSaved" and the ShowMe is run over again from scratch. Since the re-run starts at bar number "MaxBarsBack", I don't have the data for the "someSpecificCondition" function to execute.
Here is actual code that should plot a line between the lowest low points between each high point.
If High > High[CurrentBar - vHighIndex] Then Begin
vHighIndex = CurrentBar;
Plot2[CurrentBar - vLowIndex](CurrentBar - vLowIndex);
vLowIndex = CurrentBar;
End Else If Low < Low[CurrentBar - vLowIndex] Then Begin
vLowIndex = CurrentBar;
End;
Does this make sense?
Can anyone lend any insight?
Can you help answer these questions from other members on NexusFi?
welcome to NexusFi. This is expected behavior due to the way MaxBarsBack works within Tradestation.
In general, it is better to avoid looking back, if possible. For your case that could mean saving the High of the bar when your conditions are true.
If you must go back to that bar for that plot, you will have to accept this behavior. In that case using more historical data and allowing for large MaxBarsBack values
might be the way to go. Alternatively, you could use drawings for the display instead of a plot and not affect the max bars back value.
Thank you for the comment. Its good to know that this is a system feature and not a user mistake. I will find another way to accomplish what I am trying to do (such as Drawings as you recommended). Thank you!