Thanks in advance for the help.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Indicator paint bars between Entry Trade
Collapse
X
-
Indicator paint bars between Entry Trade
Hi, I would like to develop an Indicator that paint the bars in a trade of green color if the entry was profitable, and red color if trade wasn't profitable. I know how to set the bar's color, but I wonder how can I get the start and end price's and bar's index of an entry to paint them.
Thanks in advance for the help. -
Hello ricardo88,
Thank you for the post.
To know what bar you entered the market at, when you use EnterLong()/EnterShort(), save the CurrentBar value as a protected integer in your class like so:
public class MyIndicator : Indicator
{
#region Variables
private int barsAgo;
#endregion
...
protected override void OnBarUpdate()
{
if(condition == true) {
barsAgo = CurrentBar;
EnterLong();
}
}
When you close the position, you will do the same thing to get the bar that the exit occurred on.
More on CurrentBar here:
You might also find the Position object useful, which has the AvgPrice property.
More info on Position object here:
Please let us know if we may be of any further assistance.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 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
554 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