Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stochastics fall below 20 & then move above 30 to trigger buy signal

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

    Stochastics fall below 20 & then move above 30 to trigger buy signal

    Hi, This is my first post. I have been using Ninja Trader for few weeks and think its an excellent tool for trading.

    I have been creating few stragies using the wizard and some manual coding.

    But i just cant figure out how to code the following using the wizard or by coding:

    if Stochastics(3, 5, 3) falls below 20

    && eventually Crosses above 30

    {
    EnterLong
    }



    Any help would be appreciated.

    Thanks

    #2
    sagatr, there are quite a few ways to go about this, but you'll have to actually code it out. The best way would probably be to use a boolean (true/false) variable that stores information about if the stochastics have fallen below 20. Then, you can check for the cross above along with the boolean to decide if the value was below 20 and has gone above 30. In pseudo-code, it would look something like this:
    Code:
    private bool isBelowTwenty = false;
    OnBarUpdate()
    {
        if (CrossAbove(Stochastics, 30) && isBelowTwenty)
           EnterLong();
    
        if (Stochastics < 20)
          isBelowTwenty = true;
        else
          isBelowTwenty = false;
    }
    If you need coding assistance, you can contact one of our 3rd party NinjaScript consultants.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    66 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X