Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

prints only 1 crossover.

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

    prints only 1 crossover.

    i just want to print the when a crossover happens. it only prints the last crossover. am i missing something in the drawtext function?

    Code:
    	public class S_Trading_System : Indicator
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom Indicator here.";
    				Name								= "S_Trading_System";
    				Calculate							= Calculate.OnEachTick;
    				IsOverlay							= true;
    				DisplayInDataBox					= true;
    				DrawOnPricePanel					= true;
    				DrawHorizontalGridLines				= true;
    				DrawVerticalGridLines				= true;
    				PaintPriceMarkers					= true;
    				ScaleJustification					= NinjaTrader.Gui.Chart.ScaleJustification.Right;
    				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
    				//See Help Guide for additional information.
    				IsSuspendedWhileInactive			= true;
    			}
    			else if (State == State.Configure)
    			{
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			//Add your custom indicator logic here.
    			// Only process entry signals on a bar by bar basis (not tick by tick)
         if (IsFirstTickOfBar)
         {
              if(CrossAbove(EMA(9),EMA(22),1))
                   Draw.Text(this, "crossabove" + Bars.TickCount, "look for long" , 1, Low[1]);
              return;
         }
     
         // Process 
         
    		}
    	}
    }

    #2
    Hello junkone,

    Thanks for writing in and I am reviewing your code.

    Please bear with me.

    Comment


      #3
      Hello junkone,
      Thanks for waiting and writing in.
      After closely testing your code, I found that Draw.Text() method is being replicated on the chart, it looks like it being drawn once. Bars.TickCount refers the current TickCount for your chart. Change Bars.TickCount to CurrentBar because CurrentBar refers to the current bar in the Bars object within the OnBarUpdate method. Refer to the following link for more information - http://ninjatrader.com/support/helpG...currentbar.htm

      Feel free to contact me with NinjaTrader questions or inquires.

      Comment


        #4
        thanks for your help

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        17 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        16 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        9 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        36 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X