I want the user to be allowed to use the strategy on multiple charts at the same time.
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
MarketPosition.Flat and multiple charts
Collapse
X
-
MarketPosition.Flat and multiple charts
I created a strategy and am trying to backtest on GC CL RTY YM AND NQ at the same time. If my code uses market position == flat to AtmStrategyCreate() wil it only activate 1 chart at a time until the trade is over or is it entries per postition.Or do I have to modify OrderHandling?
I want the user to be allowed to use the strategy on multiple charts at the same time.Tags: None
-
Hello ballboy11,
Thanks for your post.
I should first note that backtesting Atm strategy methods will only work in the Playback Connection since those methods only work when the NinjaScript State is State.Realtime.
NinjaScript strategies also run independently of each other. Even if you add multiple instances of a strategy to the same chart, those strategies will be separate instances and will have a separate strategy positions.
Atm strategies will also have a separate position from the NinjaScript strategy position, so I would not recommend checking if the NinjaScript strategy position is flat before having it enter an Atm strategy.
If we look at the SampleAtmStrategy source code, we can see that the Atm strategy position is fetched with GetAtmStrategyMarketPosition() and a unique Atm strategy Id is created with GetAtmStrategyUniqueId() when the Atm Strategy is created. Since this is a unique ID whenever an Atm strategy is created, separate NinjaScript strategies that will effectively have their own Atm strategies that are unique to each calling NinjaScript.
The SampleAtmStrategy example can be used for further reference when using Atm strategies within NinjaScript. Additional documentation reference can be found below.
Using Atm Strategies in NinjaScript - https://ninjatrader.com/support/help...strategies.htm
Atm Strategy Methods - https://ninjatrader.com/support/help...gy_methods.htm
Please let us know if you have any additional questions.JimNinjaTrader Customer Service
-
I am connected to my datafeed and am testing the trade live. I created a SIM accounts on GC CL NQ RTY and YM. My Strategy are all enabled and pointed to the according accounts. So if Position.MarketPosition == MarketPosition.Flat will not affect the other charts. It will only look if flat for the given chart? Or do I have to say if market position is flat for the given chart?
Example if Market position is not flat check to see what chart has a trade in. If your instrument is flat then set up a trade.
So is there a way to see if an Instrument is flat not the MarketPositon?
Comment
-
Hello ballboy11,
So if Position.MarketPosition == MarketPosition.Flat will not affect the other charts. It will only look if flat for the given chart? Or do I have to say if market position is flat for the given chart?
Position represents that strategy's position for the iterating instrument. If you are trying to reference that strategy's position on another instrument in a multi series NinjaScript you should use Positions.
Atm strategy positions are separate from NinjaScript strategy positions. Atm Strategy methods do not create positions owned by the NinjaScript strategy. As such, Position will not show a position from an Atm strategy. GetAtmStrategyMarketPosition() should be used to get that Atm strategy's position.
Position - https://ninjatrader.com/support/help...s/position.htm
Positions - https://ninjatrader.com/support/help.../positions.htm
Strategy vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
So is there a way to see if an Instrument is flat not the MarketPositon?
Account.Positions - https://ninjatrader.com/support/help...ns_account.htm
Please let us know if we can be of further assistance.JimNinjaTrader Customer Service
Comment
-
AtmStrategy within a Strategy
I know my strategy is working but I am not sure if my strategy parameters are set properly.
The image below are my parameters for my strategy.
I am not sure if i am setting the parameters correctly for 5 different charts.
I am using Strategy create. It works well on backtesting and even live but I am not sure if I have 5 charts running it will run seperate from each other.
AtmStrategyCreate(OrderAction.Buy,OrderType.Market ,0,0,TimeInForce.Day,orderId,AtmStrategy,atmStrate gyId, (atmCallbackErrorCode, atmCallBackId) =>
{
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
{
isAtmStrategyCreated = true;
// bTrade1Entered = true;
}
});
Comment
-
Hello ballboy11,
I am using Strategy create. It works well on backtesting and even live but I am not sure if I have 5 charts running it will run seperate from each other.
GetAtmStrategyUniqueId() - https://ninjatrader.com/support/help...gyuniqueid.htm
I would recommend testing the bundled SampleAtmStrategy NinjaScript included with the platform in a similar context to what you are trying to accomplish on multiple charts, and then to apply the same behavior to your custom strategy.
Please let us know if you have any further questions.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, Today, 09:30 AM
|
2 responses
11 views
0 likes
|
Last Post
by bltdavid
Today, 11:24 AM
|
||
Started by f.saeidi, Today, 11:02 AM
|
1 response
4 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by geotrades1, Today, 10:02 AM
|
4 responses
12 views
0 likes
|
Last Post
by geotrades1
Today, 11:08 AM
|
||
Started by rajendrasubedi2023, Today, 09:50 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 10:57 AM | ||
Started by lorem, Today, 09:18 AM
|
2 responses
11 views
0 likes
|
Last Post Today, 10:55 AM |
Comment