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
OnEachTick and OnBarClose
Collapse
X
-
OnEachTick and OnBarClose
I have a function in my strategy that depends on OnBarClose calculation to draw an object but I have other functions inside OnBarUpdate() that need OnEachTick calculation. Is this possible?Tags: None
-
Hello TraderMatt83,
Thank you for your post.
Yes, this is possible. You would need to set the strategy to calculate On Each Tick, and then within your logic for anything that requires updates On Bar Close, you can add a check to see if IsFirstTickOfBar is true. This is because a bar's close is determined by the first tick of a new bar forming. Here is the help guide page about IsFirstTickOfBar:
Additionally, we have a reference sample that demonstrates how to separate logic to calculate either on each tick or on bar close:
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
-
-
Emily,
I finally got this to work except not sure how to fix my issue where my trade is no longer taking the trade if the previous closing bar is above a range. This function below determines whether to go long if the previous candle close is above the range high but it appears to be taking the trade below the range high. And I know the range high is correct because I have it painted. Yet the entry always happens if the current candle hits the range high. Thoughts?
private bool entryLongCheck()
{
return Close[1] > rangeHigh && Close[2] <= rangeHigh && High[0] > High[1] && CurrentBar - lastTradeBarLong > 2 && Close[0] > rangeLow;
}
Comment
-
Emily,
I finally got this to work except not sure how to fix my issue where my trade is no longer taking the trade if the previous closing bar is above a range. This function below determines whether to go long if the previous candle close is above the range high but it appears to be taking the trade below the range high. And I know the range high is correct because I have it painted. Yet the entry always happens if the current candle hits the range high. Thoughts?
private bool entryLongCheck()
{
return Close[1] > rangeHigh && Close[2] <= rangeHigh && High[0] > High[1] && CurrentBar - lastTradeBarLong > 2 && Close[0] > rangeLow;
}
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,406 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
98 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
160 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
9 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment