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 frslvr, 04-11-2024, 07:26 AM
|
9 responses
120 views
1 like
|
Last Post
by caryc123
Today, 03:12 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
4 responses
15 views
0 likes
|
Last Post
by rocketman7
Today, 02:56 PM
|
||
Started by selu72, Today, 02:01 PM
|
1 response
9 views
0 likes
|
Last Post Today, 02:17 PM | ||
Started by WHICKED, Today, 02:02 PM
|
2 responses
14 views
0 likes
|
Last Post
by WHICKED
Today, 02:15 PM
|
||
Started by f.saeidi, Today, 12:14 PM
|
8 responses
21 views
0 likes
|
Last Post
by f.saeidi
Today, 01:55 PM
|
Comment