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 lorem, Yesterday, 09:18 AM
        5 responses
        16 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Spiderbird, Today, 12:15 PM
        0 responses
        5 views
        0 likes
        Last Post Spiderbird  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        12 responses
        42 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        6 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X