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 AaronKoRn, Today, 09:49 PM
    0 responses
    7 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Today, 08:42 PM
    0 responses
    9 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Today, 07:51 PM
    0 responses
    10 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,980 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X