• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Do I need a Multi-Time Frame Script?

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

    Do I need a Multi-Time Frame Script?

    Hi All,

    I have a script that trades on 1 minute bars. I want to add a filter to it so that it does not trade when the 14 day ATR on daily bars for the same instrument is below or above a certain level. Is there an easier way to get that 14 day ATR on daily bars reading (value) that does involved having the develop a multi-time frame script, which at my level of programming seems complicated? I mean, the script only needs to check this condition once at the beginning of the session and say "go" or "no go". Everything else is based on the 1 minute bars.

    Any help is greatly appreciated.

    #2
    Hello GeoOrtiz,

    Thank you for writing in. Unfortunately this would either require a multi time frame script or a rewriting of the ATR indicator. With that being said, I have created an example that will let you ignore most of the issues that are commonly associated with working with multi time frame scripts:
    Code:
    #region Variables
      private ATR myATR;
    #end region
    protected override void Initialize()
    {
    Add(PeriodType.Day, 1);
    myATR = ATR(BarsArray[1], 14);
    CalculateOnBarClose = true;
    }
    protected override void OnBarUpdate()
    {
      if(BarsInProgress == 0)
      {
        //Everything that you usually put inside OnBarUpdate would go inside here
        //myATR[0] is the most recent value of the 14 day ATR
      }
    }
    Please let me know if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thank you MichaelM! I played around with your code and made it work for my purposes. I did have a problem with the "myATR = ATR(BarsArray[1], 14);" statement, but I figure out another way to do it. Thanks again!

      Comment


        #4
        Hello GeoOrtiz,

        Thank you for the update. I am glad to hear you were able to make the code work for your purposes.

        Please let me know if I may be of further assistance anytime.
        Michael M.NinjaTrader Quality Assurance

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by HiddenPhilosopher, Today, 07:24 PM
        0 responses
        6 views
        0 likes
        Last Post HiddenPhilosopher  
        Started by dkbyond, Today, 06:43 PM
        0 responses
        5 views
        0 likes
        Last Post dkbyond
        by dkbyond
         
        Started by i2w8am9ii2, Today, 06:05 PM
        0 responses
        2 views
        0 likes
        Last Post i2w8am9ii2  
        Started by YevhenShynkarenko, Today, 05:46 PM
        0 responses
        4 views
        0 likes
        Last Post YevhenShynkarenko  
        Started by Bionian, Today, 04:14 PM
        0 responses
        5 views
        0 likes
        Last Post Bionian
        by Bionian
         
        Working...
        X