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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        160 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        307 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        348 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        178 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X