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

Getting current day indicator value in a multi time series strat. (OnBarClose = true)

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

    Getting current day indicator value in a multi time series strat. (OnBarClose = true)

    Hello! Can you please advise on how can I get the current value of an indicator (for example SAR) of the current day from a secondary daily data series if my strategy runs in OnBarClose mode? For getting OHLC values I use Bars.GetOpen()/GetHigh()/GetLow and GetClose. Is there any analogue for indicators' data?

    #2
    Hello,

    Thank you for the post.

    I wanted to clarify, are you trying to access the SAR for the Daily bars from a more granular timeframe?

    There are two ways to use each indicator, you can call the indicator for the current series or you can supply a series to it. If you are referring to getting the Daily value or the value using the daily bars, you could pass a daily bar series to the SAR:

    Code:
    ParabolicSAR(ISeries<double> input, double acceleration, double accelerationStep, double accelerationMax)[int barsAgo]
    This would be:
    Code:
    ParabolicSAR(BarsArray[1], 0.2, 0.2, 0.2)[0]
    
    BarsArray[IndexOfYourDailyBars]

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse! Thank you for your answer!

      I am trying to access the Daily SAR current day value from a 5 minute time frame within a strategy that runs in OnBarClose mode.

      In State == State.DataLoaded I am adding the SAR indicator using the formula that you have provided (and assigning it to a variable - "dailySar"), but later when I access this variable from the OnBarUpdate() method like "dailySar[0]" I am receiving the value of the previous day SAR - not the current day because the strategy runs in OnBarClose mode and 0 bar on the Daily time frame is previous day, since current day is not yet closed.

      So my question is how I can get the current value of the Daily SAR while my strategy runs in OnBarClose mode on a more granular time frame?

      Comment


        #4
        Hello,

        Thank you for the reply.

        Yes, that would be the case when using OnBarClose. To get the current value, you would need to be able to reference the current bar but that would only be available when running the script OnEachTick or OnPriceChange.

        You would very likely need to change to using OnEachTick or OnPriceChange and If that were to affect your logic, you would likely need to convert your script to also use IsFirstTickOfBar to simulate OnBarClose events for that portion of your logic.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          OK, got it! Thank you!

          Comment


            #6
            But what about using the strategy analyser (or historical fill) - the strategy will run in OnBarClose mode anyway. So using OnEachTick mode will help only in real time run, am I right?

            Comment


              #7
              Hello,

              Thank you for the reply.

              Correct referencing the building bar in this way would only be valid in realtime where OnEachTick can be used.

              Please let me know if I may be of additional assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by frankthearm, Today, 09:08 AM
              6 responses
              24 views
              0 likes
              Last Post frankthearm  
              Started by maybeimnotrader, Yesterday, 05:46 PM
              3 responses
              23 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by adeelshahzad, Today, 03:54 AM
              5 responses
              32 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by stafe, 04-15-2024, 08:34 PM
              7 responses
              32 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by merzo, 06-25-2023, 02:19 AM
              10 responses
              823 views
              1 like
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X