• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Keeping First Buy/Sell Signal

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

    Keeping First Buy/Sell Signal

    Dear Support,

    A simple indicator draws many buy and sell arrows when price is above and below RSI 50 line.

    I am looking for a sample script that will keep only the first instance of a buy signal and will not draw another buy signal until after a sell signal, and so on.

    I know we can use a crossover method for the case of RSI, however, I am looking for a method in general to keep only the first instance of a signal until after an opposing signal is generated.

    Many thanks.
    Last edited by aligator; 03-11-2019, 12:18 PM.

    #2
    Hello aligator,

    Thanks for your post.

    We do not have a helper method available for this task, but you could use bools to control the logic so it only occurs once until the some other logic resets the bool. For example:

    Code:
    private bool SingalActive = false;
    protected override void OnBarUpdate()
    {
        // Our signal which should only be fired once.
        if (Close[0] < Open[0] && !SignalActive)
        {
            //Do Something once here. It will happen only the first time this condition becomes true.
    
            SignalActive = true;
        }
    
        // Opposing signal, when the bool should be reset.
        if (Close[0] > Open[0] && SignalActive)
        {
            //Do Something once here
    
            SignalActive = false;
        }
    }
    Please let us know if we can be of further assistance
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello aligator,

      Please let us know if we can be of further assistance
      Thanks so much Jim, perfect.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Rashid Garuba, Today, 11:37 AM
      0 responses
      3 views
      0 likes
      Last Post Rashid Garuba  
      Started by elkhatabi, Today, 11:19 AM
      0 responses
      4 views
      0 likes
      Last Post elkhatabi  
      Started by hurleydood, Today, 10:07 AM
      0 responses
      5 views
      0 likes
      Last Post hurleydood  
      Started by Irukandji, Today, 09:43 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ThomasC  
      Started by TazoTodua, Today, 09:06 AM
      0 responses
      7 views
      0 likes
      Last Post TazoTodua  
      Working...
      X