• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
    https://ninjatrader.com/support/foru...ead.php?t=6651

    Also, see this reference sample on exposing values from a custom indicator that are not plots.
    https://ninjatrader.com/support/foru...ead.php?t=4991

    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 frankduc, Today, 07:02 AM
    0 responses
    0 views
    0 likes
    Last Post frankduc  
    Started by i2w8am9ii2, Today, 06:57 AM
    0 responses
    1 view
    0 likes
    Last Post i2w8am9ii2  
    Started by sidviciousX, Today, 06:47 AM
    0 responses
    1 view
    0 likes
    Last Post sidviciousX  
    Started by buzzripper, Today, 06:14 AM
    0 responses
    1 view
    0 likes
    Last Post buzzripper  
    Started by NinjaCustomer, Today, 06:04 AM
    0 responses
    5 views
    0 likes
    Last Post NinjaCustomer  
    Working...
    X