Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi time frame

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

    Multi time frame

    Hello:i add 1minute data on a 4min chart, if i use
    Code:
    Lows[1][0] < Closes[1][1]
    to ExitLong everything is ok, if i use
    Code:
    Lows[1][0] < Lows[1][1]
    to ExitLong everything is wrong, it will ExitLong after 100bars after enter, see photo.

    Code:
    else if (State == State.Configure)
                {
                    AddDataSeries(BarsPeriodType.Minute, 1);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0)
                    return;
    
                if (CurrentBars[0] < 1)
                    return;
    
                 // Set 1
                if (
                    Low[0] < Close[1]
    
                                     && (
                                 (BarsSinceExitExecution(0, "", 0) > 10)
                              || (BarsSinceExitExecution(0, "", 0) == -1)
                        )
    
                    )
                {
    
    
                    EnterLong(Convert.ToInt32(DefaultQuantity), "");
                }
    
                 // Set 2
    
    
                if (
                     Lows[1][0] < Lows[1][1]
                //    Lows[1][0] < Closes[1][1]
                    )
                {
                    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
                }
    
            }​
    Attached Files
    Last edited by bill2023; 11-25-2023, 02:04 PM.

    #2
    Hello bill2023,

    Thank you for your inquiry.

    Your conditions are checking 2 different things, so it is expected the strategy will not perform the same. Lows[1][0] < Lows[1][1] is checking that the current Low of the secondary data series is less than the Low of the secondary series 1 bar ago. Lows[1][0] < Closes[1][1] is checking that the current Low of the secondary data series is less than the Close of the secondary series 1 bar ago.


    In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.

    Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

    https://ninjatrader.com/support/foru...121#post791121

    Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.

    Let me know if you need any assistance creating a print or enabling TraceOrders.

    Save the output from the output window to a text file and provide this with your reply.

    I'll be happy to assist with analyzing the output.


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X