• 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

  • aligator
    started a topic Keeping First Buy/Sell Signal

    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.

  • aligator
    replied
    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.

    Leave a comment:


  • NinjaTrader_Jim
    replied
    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

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Conall, Today, 06:11 AM
0 responses
3 views
0 likes
Last Post Conall
by Conall
 
Started by Vincere, Yesterday, 11:20 PM
1 response
10 views
0 likes
Last Post NinjaTrader_PaulH  
Started by uday12, Yesterday, 10:07 PM
1 response
4 views
0 likes
Last Post bltdavid  
Started by cnecorp, Today, 03:04 AM
3 responses
18 views
0 likes
Last Post cnecorp
by cnecorp
 
Started by bxl2019, Yesterday, 07:59 AM
1 response
24 views
0 likes
Last Post NinjaTrader_ChrisSch  
Working...
X