Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need a little help with a multi timeframe strategy I am working on

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

    Need a little help with a multi timeframe strategy I am working on

    I used the strategy builder to create a new strategy that I have been working on which includes two time frames (4mins and 240 mins) but running the strategy doesn't seem to do the right thing so something is wrong.

    The strategy is a simple crossover on an indicator I use but I want to execute the trade when Close[0] i.e closing price on my 4 min chart crosses above/below the indicator (ATRTrailingStop of the 4 min char) but also when Close[0] is > ATRTrailingStop of the 4 hour chart.

    Here is what I have in the code
    declarations
    private ATRTrailingStop ATRTrailingStop1;
    private ATRTrailingStop ATRTrailingStop2;

    in State == State.Configure
    AddDataSeries(Data.BarsPeriodType.Minute, 4);
    AddDataSeries(Data.BarsPeriodType.Minute, 240);

    in State == State.DataLoaded
    ATRTrailingStop1 = ATRTrailingStop(Close, 10, 3.03);
    ATRTrailingStop2 = ATRTrailingStop(Closes[2], 10, 3.03);

    in OnBarUpdate()

    if ((CrossAbove(Close, ATRTrailingStop1, 1))
    && (Times[0][0].TimeOfDay > new TimeSpan(6, 30, 0))
    && (Times[0][0].TimeOfDay < new TimeSpan(13, 40, 0))
    && Close[0] > ATRTrailingStop2[0])
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if ((CrossBelow(Close, ATRTrailingStop1, 1))
    && (Times[0][0].TimeOfDay > new TimeSpan(6, 30, 0))
    && (Times[0][0].TimeOfDay < new TimeSpan(13, 40, 0))
    && Close[0] < ATRTrailingStop2[0])
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    What am I missing here?
    Last edited by vpatanka; 11-28-2021, 11:01 AM.

    #2
    Hello vpatanka,

    In the Strategy Builder you can select the added series when clicking Series1 -> Input series.

    Attached is a screenshot.

    To understand the behavior of the script, it is necessary to print all values used in the condition.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior and includes a video that debugs a CrossAbove condition in the Strategy Builder.


    I am happy to assist with analyzing the output from the prints.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    132 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X