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

One indicator, two functions

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

    One indicator, two functions

    I am trying to develop an indicator with a plot and data trapping. I would like the plot to be continuous intrabar and the data trap to be at bar close, trapping the plot closing values depending on signals/variables generated by the plot, so not every bar would be trapped. Is there a way to have one function running intrabar with a second running at bar close?

    If not, is there a way for one indicator function (the data trap) to access signals/variables from a second indicator (the plot). I hate to have a second indicator calculating the same thing as the first, just so it can trap at bar close, but monitoring variables in the first might not be so cpu intensive.

    Many thanks,
    snap

    #2
    You can do this by limiting code segments in your code with this if statement:
    Code:
    if (FirstTickOfBar)
    Code inside this will be equivalent to running at the close of each bar while code outside will be evaluated at every tick update if CalculateOnBarClose to false is set.

    While you are inside the if-statement make sure you are using an index value of [1] to get to the just closed bar's values though. For instance everything should be applied to Close[1], Open[1], etc. If you forget to do this you will be getting the values of the first tick of the new bar instead of the values of the closed bar.
    Last edited by NinjaTrader_JoshP; 05-10-2008, 06:20 PM.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Waxavi, Today, 02:10 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X