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 bortz, 11-06-2023, 08:04 AM
              47 responses
              1,603 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              8 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              4 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              12 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X