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 poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,407 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    98 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    160 views
    0 likes
    Last Post loganjarosz123  
    Working...
    X