Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding conditions to a stochastic indicator

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

    Adding conditions to a stochastic indicator

    Hi

    Please could someone help me adjust a custom indicator I am creating. I have the following code that plots a triangle below the bar when the stochastic crosses, but I want to only plot the triangle when the cross happens below the low line ie 20

    // Condition set 1
    if (CrossAbove(Stochastics(7, 14, 4).K, Stochastics(7, 14, 4).D, 1))
    {
    DrawTriangleUp("My up arrow" + CurrentBar, true, 0, Low[0] + -2 * TickSize, Color.Blue);
    }

    What code should I add to only plot when the cross happens below the low line?

    Many thanks for you assistance
    Jim
    Last edited by JimBo2; 02-22-2014, 07:21 AM.

    #2
    Try

    Code:
    // Condition set 1
               if (CurrentBar < 1) return; 
               if (CrossAbove(Stochastics(7, 14, 4).K, Stochastics(7, 14, 4).D, 1) 
                   && Stochastics(7,14,4).D[1] < 20) 
                {
                    DrawTriangleUp("My up arrow" + CurrentBar, true, 0, 
                    Low[0] + -2 * TickSize, Color.Blue);
                }
    Not tested.

    Comment


      #3
      Jim,

      Thank you for your post.

      Harry's example should be what you are looking for.
      Cal H.NinjaTrader Customer Service

      Comment


        #4
        Thank you Harry

        Its working perfectly

        Much appreciated

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        606 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        353 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        561 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X