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 WHICKED, Today, 12:45 PM
    2 responses
    16 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by GussJ, 03-04-2020, 03:11 PM
    15 responses
    3,272 views
    0 likes
    Last Post xiinteractive  
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    2 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Working...
    X