Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multitimeframe problem

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

    Multitimeframe problem

    Hi, sort of example code:


    Initialize()
    Add(Period.Type.Day, 1) // this ruins everything, other timeframe minutes


    OnBarUpdate()
    if (BarsInProgress == 1 ) do something; return:

    if (Historical) return;

    if ( signalcondition which happens some time ago ) // like one hour earlier
    EnterLong(); // or some other position, this will be entered when strategy is enabled !!!!???? although should not.

    How to avoid that, this will run on backtest Ok but when enabled as a live strategy the order entry is entered, no effect with "sync account position" property.

    NT7, RC1

    #2
    Full example code, just use f.ex. NQ and minute data


    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    Add(PeriodType.Day, 1); // this ruins system
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    // if (BarsInProgress == 1 ) return; // no mater either , of course this will avoid multiple entries

    // if (Historical) return; // as mater of fact this sould have no effect and can be left out
    // Condition set 1
    if (ToTime(Time[0]) == ToTime(10, 00, 0)) // just enter earlier time from current day here
    {
    EnterLong(DefaultQuantity, ""); // this will be called when strategy enabled, should NOT, how to avoid?
    }
    }

    Comment


      #3
      Hello,

      Thanks for posting.

      I am looking into this. Thanks for your patience.

      Comment


        #4
        Hello,

        You need to make sure you have enough bars in your daily series before the indicator tried to calculate or the transition from historical to live will not be smooth. This is specially needed for the daily series bars.

        Add the following statement:

        if (CurrentBars[1] < 2) return;

        This will get your code to run.

        Let me know if I can be of further assistance.

        Comment


          #5
          Thanks,

          As matter of fact: this will do the trick although I though that "Days to Load" should do the same, which I have used.

          For Your Information:

          I used "Days to load" at strategy parameters and it will work as epected without checking Currentbars if Days to load is bigger than equal 29, does not start at all with 28 and does not work properly with less than 28 values ... (for some reason I had to switched it from 5 to 25 as it should bemore than 20 in my days indicators)

          Comment


            #6
            Hello,

            Excellent and thanks for sharing.

            Let me know if I can be of further assistance.

            Comment


              #7
              One more thing: I had to leave that if(Historical) return; from my code ...

              Comment


                #8
                still some strange behaviour but I have to track it further... might be in my code as well.

                Comment


                  #9
                  And one note: "Min. bars required" has quite impact here, better NOT to be too big!?

                  Comment


                    #10
                    Yes BarsRequired applies to all series in your MultiSeries script, so until this isn't satisfied for all series, you would not seen an OnBarUpdate() call.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Waxavi, Today, 02:10 AM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by Kaledus, Today, 01:29 PM
                    5 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Waxavi, Today, 02:00 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by alifarahani, Today, 09:40 AM
                    5 responses
                    23 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by gentlebenthebear, Today, 01:30 AM
                    3 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X