Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use Multi time frame indicator in multitime frame strategy

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

    How to use Multi time frame indicator in multitime frame strategy

    Hello,
    I have problem using my custom indicator inside my strategy:

    Indicator looks:
    Code:
                if (State == State.Configure) {
                    Calculate            = Calculate.OnEachTick;
                    IsAutoScale         = false;
                    IsOverlay            = true;
                    Name                = indicatorName;
    
                    AddPlot(new Stroke(Brushes.Lime), PlotStyle.Dot, "Potential_Long");
                    AddPlot(new Stroke(Brushes.PaleVioletRed), PlotStyle.Dot, "Potential_Short");
    
                    // Add Range Bars Time Frame [timeFrameRB]
                    AddDataSeries(BarsPeriodType.Range, iTFrbPeriod);
    
                    // Add Minutes Time Frame [timeFrameMinute]
                    AddDataSeries(BarsPeriodType.Minute, iTFminutePeriod);
    
                    // Inicializace objektu s nastavením, buď dle strategie a nebo dle trhu
                    initFailed = false;
    
                    longGaps = new List<GapItem>();
                    shortGaps = new List<GapItem>();
                }
    ​
    it works on 2 time frames
    i have strategy which uses also multi time frames looks:
    Strategy
    Code:
                else if (State == State.Configure)
                {
    
                    // Add Volumetric Time Frame [timeFrameVolumetric]
                    AddVolumetric("ES JUN23", BarsPeriodType.Range, iRangeBarSize, VolumetricDeltaType.BidAsk, 1);
    
                    // Add Entry Time Frame [timeFrameEntry]
                    AddDataSeries(BarsPeriodType.Range, iRangeBarSize);
    
                    // Add Daily Chart [timeFrameDaily]
                    AddVolumetric("ES JUN23", BarsPeriodType.Day, 1, VolumetricDeltaType.BidAsk, 1);
    
                    // Add Entry Ticks [timeFrameTicks]
                    AddDataSeries(BarsPeriodType.Tick, 1);
    ​
    these are timeframes it uses
    And I want to use GAP indicator inside strategy
    using:
    Code:
               else if (State == State.DataLoaded)
                {
                    Print("Strategy updated (State.DataLoaded) Account: " + Account.Name);
                    string strategySettings = "";
                    strategySettings += "Range bars: " + iRangeBarSize + "\n";
                    strategySettings += "Account: " + Account.Name + "\n";
                    tradesLogger.Store(tradesLoggerCsvHeader);
    
                    if (Account.Name != "Sim101")
                        SendMail("RB" + this.RangeBarSize + " Starting on Account: " + Account.Name, strategySettings, true);
    
                    // Add EMA indicator to strategy
                    emaIndicator = EMA(BarsArray[timeFrameEntry], iEmaPeriod);
                    emaIndicator.Plots[0].Brush = bEmaColor;
    
                    // Add LevelsSR indicator
                    levelsSRIndicator = Saskuj_LevelsSR(BarsArray[timeFrameEntry]);
    
                    // Add GAP Indicator
                    gapIndicatorA = Saskuj_GAP(BarsArray[timeFrameEntry], iFilterGapLookbackDays, iFilterGapMinimumSizeTicks, iTFrbPeriod, iFilterGapTFminutePeriodA, iFilterGapCancelCloseTicks, iFilterGapCancelApproachTicks, iFilterGapCancelDistancedTicks);
    ​
    but I get error message
    <b>
    'Saskuj_GAP' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load ES 06-23 Globex: 6 Range
    Click image for larger version

Name:	image.png
Views:	253
Size:	2.5 KB
ID:	1254206

    I specify tf in gapIndicatorA = .... as parameter iTFrbPeriod and iFilterGapTFminutePeriodA

    How should i solve this?​

    #2
    Hello, thanks for writing in. If you hard code this in State.Configure to use 6 Range does the error go away?
    //AddDataSeries(BarsPeriodType.Range, iRangeBarSize);
    AddDataSeries(BarsPeriodType.Range, 6);

    Or, if this is not a 6 Range series being loaded, then make sure you are adding the exact same data series in your Strategy that are being used in this Gap indicator.

    Comment


      #3
      Thanks a lot, this worked perfectly, I already understand that all timeframes used in indicator have to be added in configure in strategy.. thanks.

      Comment


        #4
        Im happy to help kujista

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 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
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X