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 Setting

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

    Multi TimeFrame Setting

    Questions:
    1- Are Entries and Exits executed only on Closing of Bars?

    2- During a Live Test, I'll like to have the following script to work:

    protectedoverridevoid OnBarUpdate()

    {
    //Only run on real-time data
    if (Historical)
    return;


    if (BarsInProgress == 0)
    {

    if (CrossAbove(SMA(1), Bollinger(BarsArray[1],2, 14).Upper, 0))


    {
    EnterLong(DefaultQuantity, "EnterLong");
    }


    What I'm looking for is to have the SMA for a 1min chart CrossAbove the Bollinger bands from another chart time such as the 1 day chart to enter a long position.

    What I've noticed during my tests is that the Position won't get entered untill the Bar for the Daily chart is closed or entered randomly. I already had set in the Initialize section the

    Add(PeriodType.Day, 1);
    CalculateOnBarClose =
    false;

    but still won't execute at the tick or at least at the closing of the 1 minute bar chart. What happens is that is waiting for the 1 day Bar to close to then enter long or the prders are entered randomly. Any suggestions?

    #2
    If CalculateOnBarClose is set to true then order submitted on close of a bar otherwise intrabar.

    For your issue, can you check if it makes a difference if you set CalculateOnBarClose to false?
    RayNinjaTrader Customer Service

    Comment


      #3
      I already had CalculateOnBarClose = false;

      Comment


        #4
        Is making no difference if I set to either true or false.

        Comment


          #5
          Thanks for checking this. The problem you are running into is that when mixing daily and intraday time frames, NT internally is waiting for the daily bar to close thus, today, you will be accessing yesterdays daily bar and not today. This is unfortunately a current limitation and one that will be resolved with NT7 planned for later this year.

          As a workaround, you could use an equivalent minute time frame? For example, there is 390 minute bars in a regular equities trading day. You could then add a 390 minute bar to your strategy to represent the daily bar.
          RayNinjaTrader Customer Service

          Comment


            #6
            I replaced the 1 day with the 5 minutes charts and still behaves the same way. Now the strategy stays there like if nothing happens.

            Comment


              #7
              Just to let you know for the expression:

              if (CrossAbove(SMA(1), Bollinger(BarsArray[1],2, 14).Upper,0))

              I changed the last "0" for a "1" and now reads:

              if (CrossAbove(SMA(1), Bollinger(BarsArray[1],2, 14).Upper,1))

              and now is working as expected. Seems that the period can't be less than 1.

              I'm still testing to make sure it works for the different time charts I'll use.

              While testing Live with the Sim account, the orders sometimes are been rejected as not enough margin met. How can I adjust this for Forex trading within the Sim account properties? I tried to do several things within the "Tools\Options\Simulator\Account" but still keeps rejecting my order sometimes.
              Last edited by Edgar V.; 03-19-2008, 02:38 PM.

              Comment


                #8
                Glad you made some progress.

                Regarding margin, go to Toos > Options > Simulator and set the cash value to some high amount and press Apply.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Done. Let see how it goes...

                  Comment


                    #10
                    So far the only problem I see is when the SMA Crosses above the Bollinger and the opening of the next 5 min bar happens to be over the Bollinger, then the Strategy is tending to ignore this and is not placing the Long position. Strategy only is working if the 5 min bar happens to open below the Bollinger and crosses the Bollinger Upper Channel.

                    What I want is to place the Long order no matter where the 5 min bar opens either below or over the Bollinger Upper as I'm using the 1 min chart to decide when to enter, not the 5 min bar.

                    Comment


                      #11
                      Any sugestions?

                      Comment


                        #12
                        Hi Edgar V,

                        From your code snippets, your entry condition is across the two time frames. It is not so much of where the close is opening but how the SMA on 1min is in relation to the Bollinger of 5min. This combination is not easily charted so one of the ways to check your condition for true is to print the values of the SMA and the Bollinger on their respective time periods. This way you can truly see when your condition should evaluate to be true. I'm suspecting that the SMA is not crossing above the Bollinger anymore when the price on 5min opens above the Bollinger 5min.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by WHICKED, Today, 12:45 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post WHICKED
                        by WHICKED
                         
                        Started by GussJ, 03-04-2020, 03:11 PM
                        15 responses
                        3,276 views
                        0 likes
                        Last Post xiinteractive  
                        Started by Tim-c, Today, 02:10 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by Taddypole, Today, 02:47 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post Taddypole  
                        Started by chbruno, 04-24-2024, 04:10 PM
                        4 responses
                        51 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Working...
                        X