Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

retrieving a variables value from a bar before or X bars before

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    retrieving a variables value from a bar before or X bars before

    Hi... I know there's a way to do this using custom series? Can I get a little help or pointer to a good example?

    1. I'm trying to build my own heiken ashi calculations inside of my strategy

    2. I have this line, which wants to reference a calculated value "ha_ThisOpen" from the previous bar, inside of its calculation.

    ha_ThisOpen = (ha_ThisOpen[1] + ha_ThisClose[1]) / 2;

    How do I properly "look back" to the value of a variable for previous X bars?

    Thank you.

    #2
    Hello halgo_boulder,

    Thanks for your post.

    This could be accomplished by using a custom Series<double> variable.

    You would create a custom Series<double> variable in your script, assign the calculation to the Series<double> variable, and then you could access previous values by passing in a barsAgo value for the Series.

    For example, if you have a Series<double> named 'ha_ThisOpen' then you could access the previous bar's value for this Series by passing in 1 for the barsAgo.

    ha_ThisOpen[1] would get the previous bar's value for this Series. Note that we pass in a 1 for barsAgo to get the previous bar value of this Series.

    See this help guide page for more information about working with custom Series: https://ninjatrader.com/support/help...t8/seriest.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    163 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    81 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    125 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    206 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    184 views
    0 likes
    Last Post CarlTrading  
    Working...
    X