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 sjsj2732, 03-23-2026, 04:31 AM
        0 responses
        74 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        313 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        311 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        148 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        111 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X