Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	196
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.
    Chris L.NinjaTrader Customer Service

    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
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Waxavi, Today, 02:10 AM
        0 responses
        4 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        10 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X