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

my indicator is returning wrong results.

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

    my indicator is returning wrong results.

    Pleaes move this question to Nijatrader 7 general discussion and also i need the answers for below.
    i set the indicator plot and i check at the firsttickofbar on next bar to see if i have a plot, then i write to a file. this logic does not work as i write for every bar even though i dont see the plot every bar
    i expect the logic behind if(Plot0[1]>0 && !Historical) to write to fiel only if i had plotted it in the code highlighted in red.
    .
    Code:
     protected override void OnBarUpdate()
            {
    				if( CurrentBar < 5)
    				return;
    			if(FirstTickOfBar)
    			{
    				[COLOR="Red"]alarmonce=true;
    				if(Plot0[1]>0 && !Historical)
    				{[/COLOR]
    					STSPullbacktrade a=new STSPullbacktrade();
    					a.entrytime=DateTime.Now;
    					a.signal="Pullback";
    					a.instrument=Instrument.FullName;
    					
    					
    					using (System.IO.StreamWriter file = 
                new System.IO.StreamWriter(@"C:\temp\" + Instrument.FullName + "signals.txt", true))
            {
                file.WriteLine(string.Format("{0},{1},{2}",a.instrument,a.signal,a.entrytime));
            }
    					
    				}
    				
    			}
    			
    		
    		
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
    			[COLOR="Red"]if(High[0] <High[1] +TickSize && Low[0] >Low[1] -TickSize )
                {
    				Plot0.Set(Close[0]);[/COLOR]
    				if(Bars.PercentComplete >.95 && alarmonce )
    			{
    				Alert(Instrument.FullName + CurrentBar,NinjaTrader.Cbi.Priority.High, "Getready for insider", "Alert1.wav", 10, Color.Black, Color.Yellow);
     alarmonce=false;
    
    			}
    			}
    			
    			else
    				Plot0.Reset();
    			
    			
    			  
            }
    Last edited by junkone; 09-19-2016, 07:18 AM.

    #2
    how do i check if the indicator plot has the value i set before i take action on it. this change also did not fix my issue
    if(Values[0].IsValidPlot(1) && !Historical)
    {

    Comment


      #3
      Hello junkone and thank you for your question. I notice you writing to a boolean variable alarmonce, but never actually reading from it. In light of this fact, I believe the following code change will allow us to continue.

      if (FirstTickOfBar && ! alarmonce)

      Please let us know if there are any other ways we can help
      Jessica P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      11 responses
      1,422 views
      0 likes
      Last Post jculp
      by jculp
       
      Started by RubenCazorla, Today, 09:07 AM
      0 responses
      4 views
      0 likes
      Last Post RubenCazorla  
      Started by BarzTrading, Today, 07:25 AM
      2 responses
      29 views
      1 like
      Last Post BarzTrading  
      Started by devatechnologies, 04-14-2024, 02:58 PM
      3 responses
      21 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by tkaboris, Today, 08:01 AM
      0 responses
      6 views
      0 likes
      Last Post tkaboris  
      Working...
      X