Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jonafare, 12-06-2012, 03:48 PM
    5 responses
    3,984 views
    0 likes
    Last Post rene69851  
    Started by Fitspressorest, Today, 01:38 PM
    0 responses
    2 views
    0 likes
    Last Post Fitspressorest  
    Started by Jonker, Today, 01:19 PM
    0 responses
    2 views
    0 likes
    Last Post Jonker
    by Jonker
     
    Started by futtrader, Today, 01:16 PM
    0 responses
    7 views
    0 likes
    Last Post futtrader  
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,791 views
    0 likes
    Last Post aligator  
    Working...
    X