Announcement

Collapse
No announcement yet.

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 Lance El Camino, Today, 04:14 PM
              1 response
              13 views
              0 likes
              Last Post s.kinra
              by s.kinra
               
              Started by jtrading82, Today, 04:56 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by dmking, Today, 06:00 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_EricB  
              Started by WHICKED, Today, 03:23 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by demarcog, Today, 02:24 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Kate  
              Working...
              X