protected override void OnBarUpdate() { if(BarsInProgress == 1 && FirstTickOfBar) { if (CurrentBar < 3) return; if ((Open[1]) >= (Close[1]))//BEARISH BAR PREVIOUS { DrawRectangle("Body", false, Math.Min(CurrentBar, -15), Open[1], Math.Min(CurrentBar, -25), Close[1], Color.Red, Color.Transparent, 1); DrawLine("High", Math.Min(CurrentBar, -20), High[1], Math.Min(CurrentBar, -20), Open[1], Color.Pink); DrawLine("Low", Math.Min(CurrentBar, -20), Low[1], Math.Min(CurrentBar, -20), Close[1], Color.Pink); DrawLine("halfwaybear", false, Math.Min(CurrentBar,-16), ((Close[1] + Open[1])/2), Math.Min(CurrentBar, -24), ((Close[1] + Open[1])/2), Color.Blue, DashStyle.Solid, 1); RemoveDrawObject("halfwaybull"); } else if ((Open[1]) <= (Close[1]))//Bullish PREVIOUS { DrawRectangle("Body", false, Math.Min(CurrentBar, -15), Open[1], Math.Min(CurrentBar, -25), Close[1], Color.Green, Color.Transparent, 1); DrawLine("High", Math.Min(CurrentBar, -20), High[1], Math.Min(CurrentBar, -20), Close[1], Color.Pink); DrawLine("Low", Math.Min(CurrentBar, -20), Low[1], Math.Min(CurrentBar, -20), Open[1], Color.Pink); DrawLine("halfwaybull", false, Math.Min(CurrentBar,-16), ((Close[1] + Open[1])/2), Math.Min(CurrentBar, -24), ((Close[1] + Open[1])/2), Color.Blue, DashStyle.Solid, 1); RemoveDrawObject("halfwaybear"); } }//if(BarsInProgress == 1 && FirstTickOfBar) if(BarsInProgress == 1 ) { if ((Open[0]) >= (Close[0]))//BEARISH BAR CURRENT { DrawRectangle("Body0", false, Math.Min(CurrentBar, -26), Open[0], Math.Min(CurrentBar, -36), Close[0], Color.Red, Color.Transparent, 1); DrawLine("High0", Math.Min(CurrentBar, -31), High[0], Math.Min(CurrentBar, -31), Open[0], Color.Pink); DrawLine("Low0", Math.Min(CurrentBar, -31), Low[0], Math.Min(CurrentBar, -31), Close[0], Color.Pink); } else if ((Open[0]) <= (Close[0]))//BULLISH BAR CURRENT { DrawRectangle("Body0", false, Math.Min(CurrentBar, -26), Open[0], Math.Min(CurrentBar, -36), Close[0], Color.Green, Color.Transparent, 1); DrawLine("High0", Math.Min(CurrentBar, -31), High[0], Math.Min(CurrentBar, -31), Close[0], Color.Pink); DrawLine("Low0", Math.Min(CurrentBar, -31), Low[0], Math.Min(CurrentBar, -31), Open[0], Color.Pink); } } // if(BarsInProgress == 1 ) }//on bar update
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Can't Get DrawRectangle To Update OnBarUpdate()
Collapse
X
-
Can't Get DrawRectangle To Update OnBarUpdate()
My indicator draws two rectangles on an intraday chart to represent the previous weekly candle and current weekly candle that is developing. Trouble is, the rectangle that represents the developing weekly candle does not update with the current price--I have to refresh the indicator before it updates. What simple solution am I missing? Thanks in advance.
Code:Tags: None
-
Hello shipolito,
Thank you for reaching out to us. I see you are using an additional data series for these calculations. To clarify, could you please provide the code you are creating the additional data series with? It will be in the Initialize() method of your indicator and should look similar to:
Add(PeriodType.Minute, 5);
or
Add("ES 12-06", PeriodType.Tick, 100);
Thank you.Michael M.NinjaTrader Quality Assurance
-
Patrick,
Thanks for your time--attached is the indicator. I hope you can replicate the issue on your side.Attached Files
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Waxavi, Today, 02:10 AM
|
0 responses
6 views
0 likes
|
Last Post
by Waxavi
Today, 02:10 AM
|
||
Started by TradeForge, Today, 02:09 AM
|
0 responses
11 views
0 likes
|
Last Post
by TradeForge
Today, 02:09 AM
|
||
Started by Waxavi, Today, 02:00 AM
|
0 responses
2 views
0 likes
|
Last Post
by Waxavi
Today, 02:00 AM
|
||
Started by elirion, Today, 01:36 AM
|
0 responses
4 views
0 likes
|
Last Post
by elirion
Today, 01:36 AM
|
||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 01:30 AM |
Comment