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 Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        68 views
        0 likes
        Last Post jeronymite  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        20 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Yesterday, 09:46 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X