Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Does order of added timeframes matter

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

    Does order of added timeframes matter

    I am trying to develop a multi timeframe strategy. I have set it to run each tick on a base time frame(15 min normally) and added a tick timeframe.
    The entries are not happening on the tick but on the 15 min even though I have them summitted to the tick timeframe. I think the problem
    is that it is doing the checks to submit the order on the higher timeframe even though I have them submitted to the tick.
    It's live the OnBarUpdate only happens once each 15 min.
    Do I have to have the smallest timeframe as my base and then add higher timeframes secondarily or is it something else?
    Pertinent code included

    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {
    EMA1 = EMA(Close, 8);
    BarCounter1 = BarCounter(Close, true, Brushes.Gray, 14, 50, true);
    EMA1.Plots[0].Brush = Brushes.Goldenrod;
    BarCounter1.Plots[0].Brush = Brushes.Transparent;
    AddChartIndicator(EMA1);
    AddChartIndicator(BarCounter1);
    SetProfitTarget(@"Long", CalculationMode.Ticks, Target);
    SetStopLoss(@"Long", CalculationMode.Ticks, Target, false);
    }
    }

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

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

    // Set 1
    if ((IsFirstTickOfBar == true)
    && (Open[1] > Close[1])
    && (Open[0] < Close[0])
    && (Low[0] < Low[1])
    && (High[0] < High[1])
    && (Close[1] > EMA1[0])
    && (BarCounter1[0] > 60)
    && (BarCounter1[0] < 79))
    {
    EntryLong = (High[0] + 1) ;
    LongConditions = true;
    BarBrush = Brushes.Gold;
    Print(@"---------Long conditions True");
    Print(Convert.ToString(Times[0][0]));
    Print(Convert.ToString(BarCounter1[0]));
    Print(Convert.ToString(EntryLong));
    Print(@"------------------------");
    }

    // Set 2
    if ((LongConditions == true)
    && ((GetCurrentBid(1)) >= EntryLong))
    {
    EnterLong(1 ,Convert.ToInt32(Contracts), @"Long");
    // LongConditions = false;
    Print(@"-----entered");
    Print(Convert.ToString(Times[0][0]));
    Print(Convert.ToString(Closes[1][0]));
    Print(@"---------------------");
    }

    // Set 3
    if (Close[0] < EMA1[0])

    {
    LongConditions = false;

    }

    #2
    Hello BrJessey,

    The line 'if (BarsInProgress != 0) return;' causes the script to only run the logic when the primary series is updating. Instead of using that line, I suggest adding a condition that checks if the BarsInProgress == 1.

    Additionally, if Calculate is set to OnEachTick and this is historical, Tick Replay needs to be enabled. Please see the forum post linked below for a detailed explanation:


    Lastly, make sure you are specifying the BarsInProgressIndex for your EnterLong() method.

    EnterLong(int barsInProgressIndex, int quantity, string signalName)

    https://ninjatrader.com/support/help.../enterlong.htm

    Please let us know if you have any other questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 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