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
How do I draw a rectangle at the OPEN of a minute based bar?
Collapse
X
-
CalculateOnBarClose setting on the indicator was true
NinjaTrader_PatrickH - THANK YOU.
You nailed it - the CalculateOnBarClose setting on the indicator was "true".
I set it to false - and everything is working now.
Thank you again!!!
-
Hello NBKing,
Thank you for your response.
Using your code I am not seeing the same behavior.
Can you advise if there are any error messages listed in the Log tab of the NinjaTrader Control Center?
In addition, even though the code sets CalculateOnBarClose to False, if you right click in the chart and select Indicators > is the indicator set to CalculateOnBarClose = True?
Leave a comment:
-
-
Originally posted by NBKing View PostHere is the code in it's full state.
I have also enclosed a screen shot - of the current bar.
You will notice how the previous bars shows the rectangle correctly.
However, the "live" bar, with the open at a different spot than the close, does not show the rectangle.
Code:public class eGap : Indicator { private int rOpacity = 2; private double rLow; private double rHigh; private Color rColor; protected override void Initialize() { Overlay = true; CalculateOnBarClose = false; } protected override void OnBarUpdate() { if (CurrentBar < 1) return; // if( ! FirstTickOfBar) // return; if (Open[0] != Close[1]) { if (Open [0] > Close[1]) { rLow=Close[1]; rHigh=Open[0]; } else { rHigh=Close[1]; rLow=Open[0]; } rColor = Color.White; DrawRectangle("Region1"+ CurrentBar.ToString(), false, 1, rLow, 0, rHigh, Color.Empty, rColor, rOpacity); } }
Leave a comment:
-
Details
Here is the code in it's full state.
I have also enclosed a screen shot - of the current bar.
You will notice how the previous bars shows the rectangle correctly.
However, the "live" bar, with the open at a different spot than the close, does not show the rectangle.
Code:public class eGap : Indicator { private int rOpacity = 2; private double rLow; private double rHigh; private Color rColor; protected override void Initialize() { Overlay = true; CalculateOnBarClose = false; } protected override void OnBarUpdate() { if (CurrentBar < 1) return; // if( ! FirstTickOfBar) // return; if (Open[0] != Close[1]) { if (Open [0] > Close[1]) { rLow=Close[1]; rHigh=Open[0]; } else { rHigh=Close[1]; rLow=Open[0]; } rColor = Color.White; DrawRectangle("Region1"+ CurrentBar.ToString(), false, 1, rLow, 0, rHigh, Color.Empty, rColor, rOpacity); } }
Leave a comment:
-
Originally posted by NBKing View PostI am trying to draw a rectangle at the OPEN of a 15 minutes bar highlighting the gap between the close of the previous bar, and the open of the current bar.
My code seems to work for all previous bars - HOWEVER, I cannot seem to be able to call the draw function WHEN the bard is OPENED. It seems to draw after the bar is closed - which is too late for me.
Code:protected override void Initialize() { Overlay = true; CalculateOnBarClose = false; } protected override void OnBarUpdate() { if (CurrentBar < 1) return; if (Open[0] != Close[1]) { DrawRectangle("Region"+ CurrentBar.ToString(), ......); //This section does the right thing. } }
What can I do to fix it?
Thank you.
Leave a comment:
-
Hello NBKing,
Thank you for your post and welcome to the NinjaTrader Support Forum!
I am not seeing the same item on my end unless the Open[0] is the same as Close[1]. Can you provide a screenshot of this on your end on the current bar?
Leave a comment:
-
How do I draw a rectangle at the OPEN of a minute based bar?
I am trying to draw a rectangle at the OPEN of a 15 minutes bar highlighting the gap between the close of the previous bar, and the open of the current bar.
My code seems to work for all previous bars - HOWEVER, I cannot seem to be able to call the draw function WHEN the bard is OPENED. It seems to draw after the bar is closed - which is too late for me.
Code:protected override void Initialize() { Overlay = true; CalculateOnBarClose = false; } protected override void OnBarUpdate() { if (CurrentBar < 1) return; if (Open[0] != Close[1]) { DrawRectangle("Region"+ CurrentBar.ToString(), ......); //This section does the right thing. } }
What can I do to fix it?
Thank you.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, 04-17-2024, 06:40 PM
|
6 responses
48 views
0 likes
|
Last Post
by algospoke
Today, 06:18 PM
|
||
Started by arvidvanstaey, Today, 02:19 PM
|
4 responses
11 views
0 likes
|
Last Post Today, 04:08 PM | ||
Started by samish18, 04-17-2024, 08:57 AM
|
16 responses
61 views
0 likes
|
Last Post
by samish18
Today, 03:30 PM
|
||
Started by jordanq2, Today, 03:10 PM
|
2 responses
9 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
21 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
Leave a comment: