Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mutli time Frame help needed

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

    Mutli time Frame help needed

    Hi I want to enter a trade using 60 minutes strategy and entering into the trade on the 5 min chart..However for some reason it enters on the second candle (60 min) can you please check out the code and HELP ME with this. ALSO please look at the Picture better understanding.


    Code:
        [Description("Enter the description of your strategy here")]
        public class LOWHIGHTEST : Strategy
        {
            #region Variables
            // Wizard generated variables
            private int myInput0 = 1; // Default setting for MyInput0
            // User defined variables (add any user defined variables below)
            #endregion
    
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {Add(PeriodType.Minute, 1);
                SetProfitTarget("", CalculationMode.Percent, 1);
                SetStopLoss("", CalculationMode.Ticks, 250, false);
    
                CalculateOnBarClose = false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    			if (BarsInProgress == 0)
    			{   
                if (Range () [1] > 2)
                {
                    EnterLong(1,1, "Long: 5min");
                }
    		}
    		// When the OnBarUpdate() is called from the secondary bar series, do nothing.
    			else	
    			{
    				return;
    			}
            }
    Attached Files

    #2
    Hello,

    Here is your issue:

    if (BarsInProgress == 0)
    {
    if (Range () [1] > 2)
    {
    EnterLong(1,1, "Long: 5min");
    }

    So this will EnterLong as soon as BarsInProgress 0 calculates. Which is at the close of the 60 min bars which is working as expected.


    You would need to change this entry logic to run on the 5 min bars instead. However if you ran the strategy live there would be no issue since you can run COBC = false and this will submit in realtime. However it backtest or historical it always runs COBC = true as we discussed in your other thread.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      First of all thank you for replaying back to me so soon. However, can you please advise how I should code the entry logic to run on the 5 min bars instead. This is my first time using Ninjatrader code to write a strategy. To be honest I am extremely confused I hope you can help me. thank you Ben

      Comment


        #4
        Hello,

        No problem.

        To run on the 5 min bars or the secondary series put the code inside of the following:

        if (BarsInProgress == 1)
        {

        //Run on the 5 min bars


        }


        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        103 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        52 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        34 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        36 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        73 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X