Announcement

Collapse
No announcement yet.

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

          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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            630 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            566 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X