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 NullPointStrategies, Today, 05:17 AM
    0 responses
    44 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    65 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X