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

How to add another script into chart

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

    How to add another script into chart

    I have custom class in MyCustomMethods


    Code:
    public class myPositionInfo : Indicator
    	{
    		private readonly StringFormat	far			= new StringFormat {Alignment = StringAlignment.Far};
    		private readonly Font			font1		= new Font("Arial", 9, FontStyle.Bold);
    		private readonly StringFormat	near		= new StringFormat {Alignment = StringAlignment.Near};
    		private readonly Pen			pen			= new Pen(Color.Black);
    		private readonly Brush			redbrush	= new SolidBrush(Color.FromArgb(250, Color.Red));
    
    		[Browsable(false)] public	double		OpenPl		{ get; set;}  
    		protected	override	void	Initialize()	{		Overlay = true;	}
    
    		protected	override	void	OnBarUpdate()	{}
    
    		public	override	void	Plot(Graphics graphics, Rectangle bounds, double min, double max)
    		{
    			if (ChartControl == null) 				return;
    
    			graphics.FillRectangle(graybrush,	5, bounds.Height - 67, 210, 47);
    			graphics.DrawRectangle(pen,			5, bounds.Height - 67, 210, 47);
    			graphics.DrawString("Tracked P&L :"+OpenPl, font1, redbrush, 135f, bounds.Height - 35, far);
    		}
    
    	}

    However, I am unable to call (thus add it on chart) from another primary indicator, using this:

    OnStartup:


    myPositionInfo xyz = new myPositionInfo();
    Add(xyz); //<--- gives error

    How to do that?

    #2
    Hello, TazoTodua.

    Thanks for the post.

    You must make a separate indicator called myPositionInfo. The OnBarUpdate override will not be subscribed in the runtime if the indicator is not initialized by NinjaTrader in the Indicators folder.

    Please see this reference sample linked below on plotting from within a strategy. It is a custom strategy that employs a custom indicator.
    When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability


    Also, see this reference sample on exposing values from a custom indicator that are not plots.


    Please let us know if we may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by nandhumca, Today, 03:41 PM
    0 responses
    3 views
    0 likes
    Last Post nandhumca  
    Started by The_Sec, Today, 03:37 PM
    0 responses
    3 views
    0 likes
    Last Post The_Sec
    by The_Sec
     
    Started by GwFutures1988, Today, 02:48 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    6 responses
    33 views
    0 likes
    Last Post ScottWalsh  
    Started by frankthearm, Today, 09:08 AM
    10 responses
    36 views
    0 likes
    Last Post frankthearm  
    Working...
    X