Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-time frame strategy not executing.

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

    Multi-time frame strategy not executing.

    Hello,

    I have an existing strategy built through the strategy builder that I operate on the 1 minute time frame. It has no additional data series and operates as expected.

    I am trying to add another condition to this strategy through the condition builder using daily time frame data:

    RSI(<Primary>(Daily,14, 3).Avg[1] > 45
    i.e., check that yesterday's average RSI was greater than 45.

    I've added the daily data series and indicator as demonstrated here: https://paul-ninjatrader.tinytake.com/tt/MzU5OTAwNV8xMDg3NzUyMQ

    Click image for larger version  Name:	Screenshot 2021-10-08 110126.jpg Views:	0 Size:	12.3 KB ID:	1174228


    When back-testing this new strategy, the script fails to execute the action. I have confirmed various instances where conditions are fulfilled to enable the script to execute the action with this new condition, but it just doesn't.

    A comparison backtest of the old vs. new strategy shows that the old will execute, but the new will not, despite the new daily RSI condition being met in both cases.

    Your insight is greatly appreciated.

    An excerpt of the script:

    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Day, 1);
    }
    else if (State == State.DataLoaded)
    {
    VOL1 = VOL(Close);
    ROC1 = ROC(Close, 9);
    MACD1 = MACD(Close, 12, 26, 9);
    RSI1 = RSI(Close, 14, 3);
    RSI2 = RSI(Closes[1], 14, 3);
    SetStopLoss(@"SHORTLMT", CalculationMode.Percent, SETSL, false);
    SetProfitTarget(@"SHORTLMT", CalculationMode.Percent, SETPT);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 2
    || CurrentBars[1] < 1)
    return;

    // Set 1
    if ((VOL1[0] >= 10000)
    // I have omitted most of the existing 1-minute conditions and left the new daily RSI condition below.
    && (RSI2.Avg[1] > 45))
    {
    // I have omitted the action.
    }

    }

    #2
    Hello August721,

    Thanks for your post.

    In order to better understand how the code is executing, debugging steps will need to be taken. By adding prints for the values used to evaluate your conditions, outside of those conditions, you can exactly how those conditions evaluate and you observe if logic is becoming true and allowing your actions to be met.

    The first step will be to reproduce the symptoms so you can add debugging prints for testing.

    After the issue is reproduced, you will want to add debugging prints to confirm that the logic in question is being reached and allowing the actions to be taken.

    I.E.
    Code:
    if (Close[0] > Open[0])
    {
        Print("Condition became true");
        ...
    }
    If the logic is not allowing the actions to be taken, the conditions controlling those actions will need to be debugged so you can observe how they evaluate and see why they are not allowing the actions to be taken.

    I.E.
    Code:
    Print("Close: " + Close[0] + " Open: " + Open[0]);
    if (Close[0] > Open[0])
    {
        ...
    }
    The above print will tell you what the Close and Open values are and can tell you why the condition below has/has not become true. Similar steps can be taken for other kinds of conditions. You would want to print the values on the left and right of the condition to see exactly how it evaluated.

    If you are seeing your order submission logic being reached, but it is not executing, there may be an issue where the strategy is hitting an internal rule that is not allowing you to re-enter. TraceOrders can be enabled in the strategy (set in State.SetDefaults or in the Strategy Builder under Default Properties) so it prints its order feedback, and you may also observe the log tab of the Control Center for additional hints.

    Some items to check when you are taking debugging steps:
    1. Are your conditions allowing your order submission methods to be reached?
    2. Is the strategy currently in a position that is preventing it from submitting another entry order?
    3. Do you see any errors in the log tab of the Control Center or does Trace Orders give you any feedback?
    I've included some tips for debugging below. The Playback Connection can be used to replay data as if it were realtime.

    Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm
    TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm
    Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk
    Playback Connection - https://ninjatrader.com/support/help...connection.htm
    Debugging Demo - https://drive.google.com/file/d/1rOz...w?usp=drivesdk

    Please let us know if you have any questions on the debugging process.

    Comment


      #3
      Great resources. much appreciated. I went ahead and tried a few debugging prints.
      • I tried to print an order method reached with the new strategy containing the new RSI condition and daily data series. Back-tested on conditions/dates where I know it definitely should fire. Nothing.
      • Using the old, existing strategy (without the RSI condition, but with the daily data series added as above), I simply added an action to print yesterday's daily RSI. Backtest, and nothing again.
      • I then created another empty set of conditions and actions. Here I simply added an action to print yesterday's daily close. Nothing again.
      It seems that the moment I add literally any action to the strategy that references the new daily data series, it stops working.

      I'll keep trying, but perhaps this may spark some ideas.

      Thanks again.

      Comment


        #4
        Hello August721,

        To confirm, no prints are appearing at all?

        Are you adding prints outside of the condition so that this prints for every bar?

        Have you opened the NinjaScript Output window before running the script?

        Are any errors appearing on the Log tab of the Control Center?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        71 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        143 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        76 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        47 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        51 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X