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

peak indicator not working

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

    peak indicator not working

    Hi guys,

    I'm trying to design a 2 up, 1 down indicator for a peak but its not working. Could any help me??? thanks in advance. Theres no error code just that the lines won't plot.

    Code:
    protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
                
                if (CurrentBar < 5) {return;}
                
                bool PeakConditionOne = Close[1] > Close[0];
                bool PeakConditionTwo = Close[2] < Close[1];
                bool PeakConditionThree = Close[3] < Close[1];
                
                if (PeakConditionOne == true && PeakConditionTwo == true && PeakConditionThree == true)
                {    
                    int i = 0;
                    
                    for (i = 0; i < 4; i++)
                    {
                        INDLINE.Set(Close[i]);
                    }
                    
                }
            }

    #2
    It seems you want to identify when the pattern occurs. The code below makes a bar green when the pattern you have defined is identified. I dont really understand how you were trying to plot it before but this should provide the solution you need.

    Cheers.


    Code:
    
            protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "Plot0"));
                Overlay				= true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    			if (CurrentBar < 5)return;
                
                bool PeakConditionOne = Close[1] > Close[0];
                bool PeakConditionTwo = Close[2] < Close[1];
                bool PeakConditionThree = Close[3] < Close[1];
    			
               if (PeakConditionOne == true && PeakConditionTwo == true && PeakConditionThree == true)
                {    
                       BarColorSeries[0] = Color.Green; 
                }
    			
    		}
    Attached Files
    Last edited by marty087; 03-14-2015, 05:48 PM.

    Comment


      #3
      ok thanks for that what I was trying to do, sorry should have been more clear, was create a sort of arc line over the 4 bars I was using to measure peaks and troughs.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      6 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X