- After price has crossed an EMA of 9, I would like to Label this bar with a new High ( with letter A) .....
- If another candles closes Higher I would like to have that previous Higher Label removed and to have the new candle labeled as HIgh. (Old label moves to this new Candle with Letter A)
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Counter when Bar Creates new High
Collapse
X
-
Counter when Bar Creates new High
I would like to write an indicator with the following rule set but I'm not sure how to proceed.Tags: None
-
Hello r3n3v,
Thanks for your post.
When you use the Draw methods, and use the same "Tag name", when a new draw object is added with the same tag name, the first draw object is automatically removed.
Reference: https://ninjatrader.com/support/help...?draw_text.htm
You would want to check to see if the High[0] price is greater than the EMA(9)[0] and if so then check to see if it is higher than the previous high value that you would want to save into a variable. For example, create a variable like: private double prevHigh = 0;
in OnBarUpdate():
if (High[0] > EMA(9)[0] && High[0] > prevHigh) // is the high greater than the EMA and is the high greater then the previouis high?
{
prevHigh = High[0]; // save the new high
Draw.Text(this, "my tag", "A", 0, High[0] + 3 * TickSize, Brushes.Red); // place a Red A 3 ticks above the new high
}
The above would work until you reach the highest high, above the EMA(9).
Reference: https://ninjatrader.com/support/help...?draw_text.htm
-
Hello r3n3v,
Thanks for your reply.
So that will require the use of a counter which is just an int type variable.
Each time the price crosses above the EMA you would increment the counter. You would then add the counter to the tag name to create a tag name that will remain the same until the price crosses above the EMA again. That way the last one placed will remain and a new one will be created on the next cross.
Create a privte int like private int myCounter = 0;
In OnBarUpdate()
if (CrossAbove(Close, EMA(9), 1))
{
myCounter++; // increment the counter
prevHigh = 0; // reset the high for the next excursion above the EMA.
}
Then
if (High[0] > EMA(9)[0] && High[0] > prevHigh) // is the high greater than the EMA and is the high greater then the previouis high?
{
prevHigh = High[0]; // save the new high
Draw.Text(this, "my tag"+myCounter, "A", 0, High[0] + 3 * TickSize, Brushes.Red); // place a Red A 3 ticks above the new high
}
Comment
-
Hello r3n3v,
Thanks for your reply.
Do you see any errors in the "log" tab when you run the indicator?
If no errors then I would suggest adding a print statement to verify that the condition is becoming true.
For example, in side the { }:
Print (Time[0]+" Low[0] = "+Low[0]+" EMA9[0] = "+EMA(9)[0]);
The print statement sends its output to the NS window so before running the script make sure to open the window New>Ninjascript output window.
If you do not see a print then the if condition is not becoming true.
If you do see the prints then I would next look at the value of color1 and the value of myLowCounter
Comment
-
[QUOTE = NinjaTrader_PaulH; n1172608] Hola, r3n3v:
Gracias por tu respuesta.
Sin embargo, si desea adjuntar su script, puedo probarlo, żha intentado utilizar las declaraciones impresas que le aconsejé y, de ser así, qué resultados obtuvo?
[/ QUOTE]
Hello, I can't get the maximum and the minimum of an ocsilator .. I tried but it appears on the graph instead of the indicator .. you have an example .. once having the highest histogram, get -10% of the histogram (that value We will call it A for the example) .. and to choose a minimum it must meet two conditions, one must be less than "A" and a minimum of 4 histogram .. and the rise the same but inverse .. if (difewo> 0) elseLast edited by TraderElegante; 10-24-2021, 07:24 AM.
Comment
-
Hello TraderElegante,
Thanks for your post.
I am confused by your post, can you clarify how it relates to the topic title of "Counter when Bar Creates new High".
Did you mean to reply to a different topic?
Are you creating an indicator or a strategy?
I suspect that you should be creating your own topic in the correct forum (indicator or Strategy) to avoid any further confusion.
I can help you with that if you can clarify.
Comment
-
I am creating an indicator .. My doubt was that I want the maximum of an ocsilator .. from there take the -10% to take a minimum that is less or break the -10% and a minimum of 4 histogram .. how could I do it would be with an intende counter of various ways and I couldn't ..Originally posted by NinjaTrader_PaulH View PostHello TraderElegante,
Thanks for your post.
I am confused by your post, can you clarify how it relates to the topic title of "Counter when Bar Creates new High".
Did you mean to reply to a different topic?
Are you creating an indicator or a strategy?
I suspect that you should be creating your own topic in the correct forum (indicator or Strategy) to avoid any further confusion.
I can help you with that if you can clarify.
Comment
-
Attached an example in an image would be greater or less than -10% and a minimum of 4 barsOriginally posted by NinjaTrader_PaulH View PostHello TraderElegante,
Thanks for your post.
I am confused by your post, can you clarify how it relates to the topic title of "Counter when Bar Creates new High".
Did you mean to reply to a different topic?
Are you creating an indicator or a strategy?
I suspect that you should be creating your own topic in the correct forum (indicator or Strategy) to avoid any further confusion.
I can help you with that if you can clarify.
1 Photo
Comment
-
Hello TraderElegante,
Thanks for your reply and screenshot.
If I understand correctly, when your histogram creates a new high you want to then start counting bars when the histogram exceeds the +/- 10 % of that high?
If that is correct, what part are you having difficulty with? What would be your specific question?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
577 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment