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 algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      46 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      23 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X