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
IsFirstBarOfSession
Collapse
X
-
Hello GLFX005,
Thank you for your reply.
That would be correct, that logic should fire only on days other than Monday.
Please let us know if we may be of further assistance to you.
- Likes 1
-
Hello Kate,
Thank you for your reply.
Am I correct in understanding that the following logic will only happen on days that is not a Monday?
if (Time[0].DayOfWeek != DayOfWeek.Monday
&& Bars.BarsSinceNewTradingDay == 1
&& IsFirstTickOfBar
&& Close[0] < Close[1])
{
EnterShort(2, "S");
}
Leave a comment:
-
Hello GLFX005,
Thank you for your reply.
There would not be a supported method to do that - while you can separate some strategy logic to run OnBarClose and some to run OnEachTick by utilizing IsFirstTickOfBar, there's not a comparable way to move that "once per bar" logic to the end of the bar. What I'd recommend here if you want it to place the orders on the next bar after the open would be to use BarsSinceNewTradingDay == 1 and IsFirstTickOfBar to get as close to when that first bar closed as possible:
if (BarsSinceNewTradingDay == 1 && IsFirstTickOfBar)
{
EnterLong(1, "L");
}
Please let us know if we may be of further assistance to you.
Leave a comment:
-
Hello Chris, thank you for your reply.
Is there any way in the script where I can use the FirstBarOfSession to enter a trade (depending on the direction of the bar) but only if it has been fully closed, while keeping my strategy running on Calculate.OnEachTick? Currently my strategy enters on the wicks of the first bar of the day.
if (Bars.IsFirstBarOfSession
&& Close[0] > Close[1])
{
EnterLong(1, "L");
}Last edited by GLFX005; 01-20-2020, 05:02 AM.
Leave a comment:
-
Hi GLFX005, thanks for your post.
IsFirstBarOfSession will be true for the entirety of the first bar. To get it to run once at the first tick of the day, you can add a daily series and check
if(BarsInProgress == 1)// daily series
if(IsFirstTickOfBar && IsFirstBarOfSession)
//single tick condition
Please let me know if I can assist any further.
Leave a comment:
-
IsFirstBarOfSession
Hi staff,
When my strategy is set to "Calculate.OnEachTick" does the "IsFirstBarOfSession" method wait for the closure of the first bar of the day or does it trigger instantly when the first tick of the day appears?
Thank you in advance for your answer.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by adeelshahzad, Today, 11:49 AM
|
6 responses
23 views
0 likes
|
Last Post
by mcosta72
Today, 04:35 PM
|
||
Started by sidlercom80, 05-05-2020, 07:20 AM
|
4 responses
304 views
0 likes
|
Last Post
by Bidder
Today, 04:35 PM
|
||
Started by andrew56, 11-21-2017, 11:57 AM
|
6 responses
954 views
0 likes
|
Last Post
by Bidder
Today, 04:34 PM
|
||
Indicator categories collapse, CategoryDefaultExpanded/CategoryExpanded has no effect
by Shai Samuel
Started by Shai Samuel, 08-09-2022, 04:41 AM
|
6 responses
184 views
1 like
|
Last Post
by Bidder
Today, 04:32 PM
|
||
Started by TheTradingMantis, 10-31-2017, 03:18 PM
|
5 responses
1,251 views
0 likes
|
Last Post
by TheAngryCube
Today, 04:06 PM
|
Leave a comment: