NexusFi: Find Your Edge


Home Menu

 





Referencing existing historic data points


Discussion in TradeStation

Updated
    1. trending_up 1,478 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
TheCocunut
Seattle, WA
 
Posts: 2 since Oct 2022
Thanks Given: 1
Thanks Received: 0

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.

Variables:
IntrabarPersist vHighIndex(0),
IntrabarPersist vLowIndex (0);

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?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
The Backwardation Signal: How the CL Futures Curve Tells …
Commodities
Thursday May 28: GDP + Core PCE + Jobless Claims All at …
Traders Hideout
Prop Firms Are Banning Gold Trading as Record Prices Mak …
Funded Trading Evaluation Firms
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

TheCocunut,

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.

Regards,

ABCTG


TheCocunut View Post
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.

Variables:
IntrabarPersist vHighIndex(0),
IntrabarPersist vLowIndex (0);

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?


Follow me on X Reply With Quote
Thanked by:
  #3 (permalink)
TheCocunut
Seattle, WA
 
Posts: 2 since Oct 2022
Thanks Given: 1
Thanks Received: 0


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!


Reply With Quote




Last Updated on October 12, 2022


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts