I would like to draw horizontal lines of the peak (starting at the peak and up to infinity on right) of the EMA before the crossover happens. Both ways, short and long like in the picture. Can explain how we can do this in strategy builder?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Create lines based on another indicator
Collapse
X
-
Create lines based on another indicator
Hi,
I would like to draw horizontal lines of the peak (starting at the peak and up to infinity on right) of the EMA before the crossover happens. Both ways, short and long like in the picture. Can explain how we can do this in strategy builder?Tags: None
-
Hello neshnix89,
Are you wanting to wait until the crossover happens and check the last few bars for the lowest low?
Otherwise, how are you planning to predict a cross is going to happen in the future?
HighestBar(), and LowestBar() can be used to check the last few bars and get a bar number
https://ninjatrader.com/support/help...highestbar.htm
https://ninjatrader.com/support/help.../lowestbar.htm
When the cross occurs, you would need to choose how many bars backward you want to find the highest high bar or lowest low bar.
Once you have that you can save that bar number to a variable.
And on each new bar draw the start barsAgo from that bar, with the end bars ago at 0, (to keep extending it on each new bar).
Code:private int highestValueBarsAgo; private EMA myEMA7, myEMA14; myEMA7 = EMA(7); myEMA14 = EMA(14); if (CrossBelow(myEMA7, EMA(14), 1)) highestValueBarsAgo = HighestBar(EMA(7), 10); Draw.Line(this, "myLine", highestValueBarsAgo, myEMA7[highestValueBarsAgo], 0, myEMA7[highestValueBarsAgo], Brushes.Red);
Last edited by NinjaTrader_ChelseaB; 12-13-2022, 09:52 AM.Chelsea B.NinjaTrader Customer Service
-
Hello neshnix89,
Due to a limitation of not being able to set the Start bars ago for a drawing object in the Strategy Builder, it would be necessary to unlock the script and code this by hand.
Below is a link to a forum post with helpful resources on getting started with C# and NinjaScript.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello neshnix89,
Use a unique tag name each time you want to start a new drawing object.
I recommend you increment an integer as a counter to add to the tag name.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Chelsea,
Thanks for the advice. I'm able to successfully create the script. Can you advise how we are able to "exposed" the lines created so that they can be referenced from the Strategy Builder? I would like to trigger a buy at the green line and sell at the red line. Appreciate your help.
Comment
-
Hello neshnix89,
Only Plots can be exposed for the strategy builder.
Below is a link to a forum post that provides the necessary code to add a plot, make it public, and set a value.
I'm trying to expose my variables to the strategy builder so everyone can have better use of the WaveTrend indicator (it has a lot of code). Explain this to me like I am 5 because this isnt the first time I've tried to figure it out and hit a wall. What is Series? I know its like an array that stores bars. Why not just call it
Add a plot and set the plot value to the price of the line.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
71 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|
Comment