Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get indicator signals from different periods

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

    How to get indicator signals from different periods

    Hello,

    I am implementing the indicator and now I get signal bars only from the current period.
    Now, I wish to get signals from the different periods at the same time, for example from Minute 1, Minute 5 and Minute 15 periods.

    The code snippet of the signal in the current period:

    Code:
                
               // potential Buy signal 
                if (switch_sar(AkSignalType.Buy))
                {
    
                    if (CurrentTrendFilter && !current_trend_filter(AkSignalType.Buy))
                        return;
    
                    // add other filters here
    
                   // if all filters OK --> alert the sound
                    if (SoundAlert)
                    {            
                        AkEntryType entry_type = conservative_sar_filter(AkSignalType.Buy) == true ? AkEntryType.Conservative : AkEntryType.Agressive;
                        int rearm_seconds = (int)BarsPeriod.Value / RearmCount;
                        string alert_message = entry_type.ToString() + "; M" + BarsPeriod.Value.ToString() + "; " + (High[0] + TickSize).ToString(); 
    
                        Alert(SIGNAL_UP_ALERT, Priority.High, alert_message, NinjaTrader.Core.Globals.InstallDir + @"\sounds\" + SoundFile, rearm_seconds, Brushes.White, Brushes.Green);                
                    }                
                }
                // potential Sell signal 
                else if (switch_sar(AkSignalType.Sell))
                {
                    if (CurrentTrendFilter && !current_trend_filter(AkSignalType.Sell))
                        return;
    
                    // add other filters here
    
                    // if all filters OK --> alert the sound
                    if (SoundAlert)
                    {
                        AkEntryType entry_type = conservative_sar_filter(AkSignalType.Sell) == true ? AkEntryType.Conservative : AkEntryType.Agressive;
                        int rearm_seconds = (int)BarsPeriod.Value / RearmCount;
                        string alert_message = entry_type.ToString() + "; M" + BarsPeriod.Value.ToString() + "; " + (Low[0] - TickSize).ToString(); 
    
                        Alert(SIGNAL_DOWN_ALERT, Priority.High, alert_message, NinjaTrader.Core.Globals.InstallDir + @"\sounds\" + SoundFile, rearm_seconds, Brushes.White, Brushes.Red);                
                    }
                }
    How to do this in NT8 ninjascript?
    I assume, that I have to play somehow with BarsInProgress, but don't have any clue how...

    Could you , please , advise me what to do best and may be provide some examples.
    Thank you in advance!

    #2

    if your current chart is a 1 minute then BarsPerion == 0;


    AddDataSeries(Data.BarsPeriodType.Minute, 5); //BarsPeriod == 1
    AddDataSeries(Data.BarsPeriodType.Minute, 15); //BarsPeriod == 2


    in bar update to retrieve information on the chart you use

    If (BarsPeriod == 1) // 5 minute chart information
    {

    Close[0] // 5 minute chart close price etc.


    }



    Comment


      #3
      Hello akushyn,

      Thank you for your note.

      You could add additional data series to a script which calls the indicator.

      For example I have attached a sample which will add 3 plots, a plot set to the moving average of 3 different periods.

      You could swap SMA for your indicator, passing the specific series,

      See closes section of our helpguide,


      Please let us know if you need further assistance.

      Attached Files
      Alan P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      73 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      152 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X