Question 2 : I have a same strategy running on eur.usd 10 seconds and 30 seconds time frame , i set (Position.MarketPosition = MarketPosition.Flat) in strategy builder, but the second strategy still open new trades.
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
Collapse
X
-
MarketPosition.Flat
Question 1 : my strategy executes multi trades on the same bar,so in strategy builder I set condition of Bars Since Exit > 2 , it executes no trades. bars in progress untouched.
Question 2 : I have a same strategy running on eur.usd 10 seconds and 30 seconds time frame , i set (Position.MarketPosition = MarketPosition.Flat) in strategy builder, but the second strategy still open new trades.Tags: None
-
1) Setting the condition: (Bars Since Exit > 2) the very first trade cannot initiate.
Try this: (Bars Since Exit > 2) OR (Bars Since Exit == -1)
2) Setting the condition: (Position.MarketPosition = MarketPosition.Flat) should wait for your position to get flat before initiate a new trade. That's ok.
Check again your other conditions. Also check the setting "If Any" or "If All" in your Conditions panel.Last edited by KonstantinosNT; 03-09-2023, 07:16 AM.
-
Hello Bill, thanks for writing in. I agree with Konstantinos, the first question your likely never getting an initial entry order. and question 2 the MarketPosition object is only reading Strategy position, not the Account position, see Strategy Position vs Account Position. It's generally not recommended to run two strategies on the same instrument and on the same account since they have the possibility of trading against each other (one goes long and the other goes short) and they are not aware of each others position in the market.Chris L.NinjaTrader Customer Service
Comment
-
Originally posted by KonstantinosNT View Post1) Setting the condition: (Bars Since Exit > 2) the very first trade cannot initiate.
Try this: (Bars Since Exit > 2) OR (Bars Since Exit == -1)
2) Setting the condition: (Position.MarketPosition = MarketPosition.Flat) should wait for your position to get flat before initiate a new trade. That's ok.
Check again your other conditions. Also check the setting "If Any" or "If All" in your Conditions panel.
Comment
-
HI i have a similar issue where in my strategy right when i enable it it takes two trades based on two different strategies.. I went to strategy builder and generated this example from above. Do those two lines should fix my issue?
And also . what is the purpose of last line CrossoverDetected = false? Should i include it in my strategy too?
And I have && Position.MarketPosition == MarketPosition.Flat also but its part of the time filter clause. Should Market position be included as part of entry logic?
I have marketposition clause
thank you
if ((CrossoverDetected == true)
&& ((CrossoverBar[5] - (CurrentBars[0])) == -5)
&& (BarsSinceExitExecution(0, "", 0) > 2)
&& (BarsSinceExitExecution(0, "", 0) == -1))
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
CrossoverDetected = false;
}Last edited by tkaboris; 03-09-2023, 10:58 AM.
Comment
-
Hi, In both cases, you will need to use
(BarsSinceExitExecution(0, "", 0) > 2)
|| (BarsSinceExitExecution(0, "", 0) == -1) //Not &&
To create this, make a new condition group and use If Any instead of If All, then use that group along with the Crossover conditions using If All.Chris L.NinjaTrader Customer Service
Comment
-
Hi Bill, I explained why this happens in Post # 3 The strategy needs access to PositionAccount instead, unfortunately, this is not available in the builder it would need to be unlocked to read the PositionAccount object:
https://ninjatrader.com/support/help...onaccount_quan tity.htm
Kind regards,
-ChrisLChris L.NinjaTrader Customer Service
Comment
-
Hello ,
I set PositionAccount.Quantity == 0 , still have the issue.
one more question : how to use multiple time frame strategy ? when I click strategies tab then open new multiple time frame strategy , you can only select 1 time frame , how to select 2 or more time frame ?Last edited by bill2023; 03-10-2023, 02:42 AM.
Comment
-
Hi, thanks for the follow up. You may use Print() on these values to debug your script:
Print(PositionAccount.MarketPosition);
Print(PositionAccount.Quantity);
To add another data series to your script you can do this through the Additional Data screen. We also have a guide on multi time frame scripts here:
Chris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Tin34, Today, 03:30 AM
|
2 responses
15 views
0 likes
|
Last Post
by Tin34
Today, 04:11 AM
|
||
Started by sastrades, Yesterday, 09:59 AM
|
2 responses
30 views
0 likes
|
Last Post Today, 04:06 AM | ||
Started by ETFVoyageur, Today, 12:52 AM
|
1 response
15 views
0 likes
|
Last Post Today, 03:36 AM | ||
Started by lollers, Today, 03:26 AM
|
0 responses
10 views
0 likes
|
Last Post
by lollers
Today, 03:26 AM
|
||
Started by aliyahany, Today, 03:16 AM
|
0 responses
4 views
0 likes
|
Last Post
by aliyahany
Today, 03:16 AM
|
Comment