• 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 rblunsom, Today, 11:19 AM
    2 responses
    20 views
    0 likes
    Last Post guidoisot  
    Started by drewski1980, Today, 02:38 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by jfep1977, Today, 02:31 PM
    2 responses
    10 views
    0 likes
    Last Post jfep1977  
    Started by dmking, Today, 12:39 PM
    6 responses
    22 views
    0 likes
    Last Post dmking
    by dmking
     
    Started by marioresa, Today, 10:15 AM
    4 responses
    26 views
    0 likes
    Last Post marioresa  
    Working...
    X