Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X