Any help will be much appreciated
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Wizard - How add vertical lines
Collapse
X
-
Strategy Wizard - How add vertical lines
I am a newbie. How can I add verical line on a stochastic chart from top to bootom if some condtions are met. I am able to creat condition and add a diamond on the price chart. But failed to add a vertical line on the stochastic chart itself. I tried adding the vertical line from the wizard, but nothing shows up on the price chart or the indicator chart.
Any help will be much appreciated -
Nice Person,
To draw on the indicator panel you will have to open up the Stochastics indicator code and add DrawOnPricePanel = false to the Initialize() method. Then you would have to add code to draw the lines. Strategies are always added to panel 1 which is why you need to do it directly in the indicator if you want it on the indicator panel.Josh P.NinjaTrader Customer Service
-
Strategy Wizard - How add vertical lines
I added DrawOnPricePanel = false; into code as follows. while compiling
I get error message "
The name 'DrawOnPricePanel' does not exist in the current context"
I must be doing something incorrect. but I don't know what?
Here is the code
protectedoverridevoid Initialize()
{
Add(Stochastics(7, 14, 3));
Add(Stochastics(7, 14, 3));
DrawOnPricePanel = false;
CalculateOnBarClose = true;
}
protectedoverridevoid OnBarUpdate()
{
if (CrossAbove(Stochastics(7, 14, 3).D, Stochastics(7, 14, 3).K, 3))
{
DrawVerticalLine("My vertical lineblue" + CurrentBar, 0, Color.Blue);
}
Comment
-
Hello Josh ... I tried adding this code but can not compile it .. it gives similar error ... is there any sample code which I could emulate ... Basically I want to draw a vertical line on a stochastic indicator chart if the "K" crossses above the "D" value and the K is above D for three bars. I tried many times times but I could not do because the coding is not my forte. Thanks in advance for your help.Originally posted by NinjaTrader_Josh View PostNice Person,
This has to be done from the indicator code, not the strategy code.
Comment
-
Error on editing the indicator
Detailed steps and error message :
Edit NInja Scripts
Open Schocastics
While trying to add a code got a message
Changes will be lost becasue you can not save system indicator.
I Ignored it
Added "DrawOnPricePanel = false;" line after following block of codes
protected override void Initialize()
{
Add(new Plot(Color.Green, "D"));
Add(new Plot(Color.Orange, "K"));
Add(new Line(Color.DarkViolet, 20, "Lower"));
Add(new Line(Color.YellowGreen, 80, "Upper"));
den = new DataSeries(this);
nom = new DataSeries(this);
==>> DrawOnPricePanel = false;
}
Now pressed compile the code
Now received a message - Error on generating indicator.
Many lines of errors appeared in red below like
indicator \@adl.cs - The name indicator does not exist in current context CS0103 - Click for info line 145 coloum 20
etc etc
Comment
-
I reinstalled the Ninja Trader and now the errors are gone.
I edited the stochastics Indicator as follows and compiled as Stochastics1
================================================== =====
protected override void Initialize()
{
Add(new Plot(Color.Green, "D"));
Add(new Plot(Color.Orange, "K"));
Add(new Line(Color.DarkViolet, 20, "Lower"));
Add(new Line(Color.YellowGreen, 80, "Upper"));
den = new DataSeries(this);
nom = new DataSeries(this);
DrawOnPricePanel = false; // Added by me
}
Then I created a strategy using stochastics1 indicator.
=========================================
protected override void Initialize()
{
Add(Stochastic01(7, 14, 3));
Add(Stochastic01(7, 14, 3));
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(Stochastic01(7, 14, 3).K, Stochastic01(7, 14, 3).D, 1))
{
DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.Blue);
}
}
Now I used replay data . The stochastics indicator appears but the vertical lines ate not there.
What am I missing here. Will appreciate help.
Comment
-
I have attached the log image ... there are no errors.
Few more points ....
When I use other drawing objects like arrow or diamond, it does show on the price panel.
My aim is to get the objects on the indicator panel itself, and not on the price panel.
Requesting fort your help.
Is it possible that I can call someone on support line and perhaps then the matter will be sorted out in few minutes. Just an idea.
Thanks
Comment
-
Here is the code from the indicator which includes the special line also (DrawOnPricePanel = false
. Still, when I use this indicator no lines appear on the indicator panel. I see that in your case the lines are appearing. Can you attach the complete indicator code which is working with you, so that I can copy that and load it. I am a newbie, so it is quite possible that I am making some silly mistakes.
protected override void Initialize()
{
Add(new Plot(Color.Green, "D"));
Add(new Plot(Color.Orange, "K"));
Add(new Line(Color.DarkViolet, 20, "Lower"));
Add(new Line(Color.YellowGreen, 80, "Upper"));
den = new DataSeries(this);
nom = new DataSeries(this);
DrawOnPricePanel = false;
}
protected override void OnBarUpdate()
{
nom.Set(Close[0] - MIN(Low, PeriodK)[0]);
den.Set(MAX(High, PeriodK)[0] - MIN(Low, PeriodK)[0]); // PeriodK = Kperiod
K.Set(100 * SUM(nom, Smooth)[0] / (SUM(den, Smooth)[0] == 0 ? 1.0 : SUM(den, Smooth)[0])); // Smooth = SlowKperiod
D.Set(SMA(K, PeriodD)[0]); // PeriodD = SlowDperiod
}
Comment
-
Thanks a lot Austin ... it was great ... When I added this indicator code file in NT it showed a new indicator panel and shows only the K line. I want that the vertical line appears in master panel of Stochastics indicator. So I changed the panel number in the properties. After this change the vertical line show in the stochastics Panel. But the scaling on the right hand side for the "draw vertical line" indicator is very high (more than 1000) and that completley supresses the stochastics line which has teh scaling only from 0 to 100. I am using "stochastics (7,14,2)" indicator. How can I force the "draw vertical line" indicator to follow same scaling like Stochastics indicator. Thanks in advance for your help.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
56 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
132 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment