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 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 Belfortbucks, Today, 09:29 PM
      0 responses
      6 views
      0 likes
      Last Post Belfortbucks  
      Started by zstheorist, Today, 07:52 PM
      0 responses
      7 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      151 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      6 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Working...
      X