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
Determining direction in which bar opens and how to place an order accordingly.
Collapse
X
-
Determining direction in which bar opens and how to place an order accordingly.
I want to see if the current bar opens either up or down. Depending on how the bar opens, I want to submit an order. What would be the best way to go about this? And is this possible to perform during live trading (not asking if it would be profitable but rather if it is possible for ninjatrader to determine the direction in which the CURRENT bar opens in real time).Tags: None
-
Not sure what are you going to achieve here.
What is mean by determine up / down.
If you want to determine the bar whether is green bar / red bar, you can use Close[0] and Open[0]
For example :
if (Close[0] > Open[0])
--> Here is green bar and do what you want
if (Close[0] < Open[0])
--> Here is red bar and do what you want
-
Hello wowza,
Thanks for your post and welcome to the NinjaTrader forums!
In order to work with the currently forming bar on real-time (or playback with market replay) data, your strategy will need to use either Calculate.OnEachtick or Calculate.OnPriceChange. Reference: https://ninjatrader.com/support/help...?calculate.htm Using either of those calculate settings will cause the bar index of [0] to point to the currently forming bar. Close[0] in these cases will represent the current price. Close[1] will be the close price of the just-closed bar.
If you wish to compare the open price on the new bar as soon as it opens, you can use the system bool IsFirstTickOfBar to trigger a check of the open price to the close price of the previous bar, for example:
if (IsFirstTickofBar && Open[0] > Close[1])
{
// do something
}
Reference: https://ninjatrader.com/support/help...ttickofbar.htm
As forum member cincai advised, you can check a bar's direction by checking the close price to the open price, keeping in mind that the currently forming bar can change direction.
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by nandhumca, Today, 03:41 PM
|
0 responses
3 views
0 likes
|
Last Post
by nandhumca
Today, 03:41 PM
|
||
Started by The_Sec, Today, 03:37 PM
|
0 responses
3 views
0 likes
|
Last Post
by The_Sec
Today, 03:37 PM
|
||
Started by GwFutures1988, Today, 02:48 PM
|
1 response
5 views
0 likes
|
Last Post Today, 03:09 PM | ||
Started by ScottWalsh, 04-16-2024, 04:29 PM
|
6 responses
33 views
0 likes
|
Last Post
by ScottWalsh
Today, 02:57 PM
|
||
Started by frankthearm, Today, 09:08 AM
|
10 responses
36 views
0 likes
|
Last Post
by frankthearm
Today, 02:54 PM
|
Comment