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 trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    22 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Started by guillembm, Yesterday, 11:25 AM
    2 responses
    9 views
    0 likes
    Last Post guillembm  
    Started by junkone, 04-21-2024, 07:17 AM
    9 responses
    68 views
    0 likes
    Last Post jeronymite  
    Started by mgco4you, Yesterday, 09:46 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X