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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    173 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    328 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    252 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    354 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    181 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X