Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Cross above/below methods confusion...

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

    Cross above/below methods confusion...

    Hi,
    I'm confused with above/bolow methods... If I want to write simple logic - if %K crossing 20% from below up, e.g. when %K is above 20% line (or %K = 21%) then put marker and/or alert... what method should I use CrossAbove() or CrossBelow() in this case? How to stop alerts and markers when %K is more 21, e.g. %K>=22 ? Same when the %K crossing 80% from above down, e.g. when below 80% or %K= 79 then put marker/alert... Stop when %K <= 78...
    Here's what I'm actually writing and getting no signals/alerts...

    If (K[0] > 80)
    {
    If CrossBelow(K, 80, 1) //If above 80 and crossing down, e.g. below 80% line...
    {
    // Then marker/alert short
    }
    }
    Else If (K[0] < 20)
    {
    If CrossAbove(K, 20, 1) //If below 20 and crossing up, e.g. above 20% line...
    {
    // Then marker/alert long
    }
    }
    ....
    Is there any other way to write this simple logic?
    Thank you very much.

    #2
    Hello Art09,

    I would take a look at this help guide article on defining crossover conditions in the condition builder. You can setup crossing conditions in a point and click interface and then view the code for it.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you. But I'm still not clear how to create strategy for Stoch. when %K crosses %D. This is what I get and I do not think this is correct:

      if (CrossAbove(Stochastics(D, K, Smooth).DUpper, Stochastics(D, K, Smooth).DUpper, 1))
      {
      DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
      }

      With MAs it is clear and easy. But not when Stoch crosses the Stoch as above. What's the DUpper argument? Should I replace one of those with KUpper? Still confusing and not answers my question.
      Thank you.

      Comment


        #4
        You would need to select the correct plot of the Stochastics to use, as they 'expose' 2 to use (%K and %D) - http://www.ninjatrader-support.com/H...ndicators.html

        In your example you used the %D in both cases which is not the condition you seek.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by selu72, Today, 02:01 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by WHICKED, Today, 02:02 PM
        2 responses
        12 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by f.saeidi, Today, 12:14 PM
        8 responses
        21 views
        0 likes
        Last Post f.saeidi  
        Started by Mikey_, 03-23-2024, 05:59 PM
        3 responses
        51 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by Russ Moreland, Today, 12:54 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X