I meet a problem in NT8 strategy coding. I want to use 60M, and 1D two time frame. 60M's indicator signal is an order entry signal. It will be calculate by Bar Close. However I want to use 1D indicator to filter the entry. In the 1D indicator calculate, I want to use by price change to calculate. In strategy coding, In very beginning: during if (State== State.SetDefaults) part, it has "calculate = Calculate.onBarClose . How to code it. Thanks a lot.
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
Multi time frame strategy code probelm
Collapse
X
-
Multi time frame strategy code probelm
Dear NT system admin,
I meet a problem in NT8 strategy coding. I want to use 60M, and 1D two time frame. 60M's indicator signal is an order entry signal. It will be calculate by Bar Close. However I want to use 1D indicator to filter the entry. In the 1D indicator calculate, I want to use by price change to calculate. In strategy coding, In very beginning: during if (State== State.SetDefaults) part, it has "calculate = Calculate.onBarClose . How to code it. Thanks a lot.Tags: None
-
Hello wadson,
Thanks for your post and welcome to the NinjaTrader forums!
You would need to set your strategy to Calculate.OnPriceChange and then seperate your code that runs on price change and on bar update. This can be done by using the bool IsFirstTickOfBar.
For example
if (IsFirstTickOfBar)
{
// all code here is executed once per bar
}
// all code out here is executed on each price change.
For further clarity, we have an example here: https://ninjatrader.com/support/help...us/?charts.htm
Please note however that as you are using a multi-timeframe, you will need to consider which data series is calling OnBarClose() and you can use BarsInProgress value to determine this. You can then combine BarsInProgress and IsFirstTickOfBar, for example:
if (BarsInProgress == 0 && IsFirstTickOfBar)
{
// execute code here based on the first tick of the chart bar
}
A good reference for multi-timeframe or multi series coding is in the help guide section here: https://ninjatrader.com/support/help...nstruments.htmPaul H.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
6 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
||
Started by alifarahani, Today, 09:40 AM
|
6 responses
41 views
0 likes
|
Last Post
by alifarahani
Today, 03:18 PM
|
||
Started by Waxavi, Today, 02:10 AM
|
1 response
20 views
0 likes
|
Last Post Today, 03:03 PM |
Comment