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

Multi-timeframe indicator value

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

    Multi-timeframe indicator value

    Hello,

    I have a little difficulties getting the proper value for an ATR indicator with a multi-timeframe setup.

    Basically I am running a strategy on a 1-min interval. I have added a 1 Day period to my script.

    Now I would like to access the 5 day period ATR value of the prior day. Note: I am running the script on a 1-min timeframe.

    I thought I could address like this:

    Code:
    double value = ATR(BarsArray[1],5)[1];
    Meaning: the index of the added Day period = 1, 5 periods and by addressing [1] I access the prior day.

    But this doesnt give me the proper values in time. It looks like for some reason it keeps on giving me the value of yesterday and not the historical day when I run the backtest.

    #2
    Hello siroki,

    Thank you for your post.

    I am not sure I understand what is occurring. You are looking for the prior day value, but you are getting yesterday's value? As in the previous day as it would be based on your current PC time?

    Comment


      #3
      I am one step closer.

      But now it shows the ATR for the day before the day I want, and for the current day it shows a value of 0.

      For today i would like to know yesterday's ATR. For yesterday's candle I would like to know yesterday-1.. Etc etc.

      This is my code:

      Code:
              protected override void Initialize()
              {
                  CalculateOnBarClose = true;
      			Add(PeriodType.Day, 1);
              }
      
              protected override void OnBarUpdate()
              {
      			int iMultiplier = 2;
      			if(Left(Instrument.FullName,1) == "$" && Right(Instrument.FullName,3) != "JPY") {
      				iMultiplier = 4;	
      			}
      			
      			double dATR 			= Math.Round(ATR(BarsArray[1],5)[0],iMultiplier);
      			double dCurrentDayOpen 	= Math.Round(CurrentDayOHL().CurrentOpen[0],iMultiplier);
      			double dCurrentDayHigh 	= Math.Round(CurrentDayOHL().CurrentHigh[0],iMultiplier);
      			double dCurrentDayLow 	= Math.Round(CurrentDayOHL().CurrentLow[0],iMultiplier);
      
      			Print(Time[0].ToString() + " - " + Instrument.FullName + " " + dATR + " " + dCurrentDayHigh + " " + dCurrentDayLow);
      		}
              }
      Last edited by siroki; 05-22-2014, 11:01 PM.

      Comment


        #4
        One step closer again. I changed the CalculateOnBarClose to FALSE. Now it shows the proper values.

        BUT

        Is it possible to set this value ONLY for the added Day period? I still want my 1-min timeframe to calculate on bar close = true.

        Comment


          #5
          Hi Siroki, that property would not be directly usable on a per series basis. However there's a workaround involving FirstTickOfBar that would come in handy in case you want to process more individually - http://www.ninjatrader.com/support/f...ad.php?t=19387
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Ah great! What I did now was set a boolean value to Checked=True on the FirstTickOfBar when the criteria has been hit. This way I dont get a flood of signals on each tick. A little creativity solved all problems

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by timmbbo, Today, 08:59 AM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by KennyK, 05-29-2017, 02:02 AM
            2 responses
            1,281 views
            0 likes
            Last Post marcus2300  
            Started by fernandobr, Today, 09:11 AM
            0 responses
            2 views
            0 likes
            Last Post fernandobr  
            Started by itrader46, Today, 09:04 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by bmartz, 03-12-2024, 06:12 AM
            5 responses
            33 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Working...
            X