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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X