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
So many orders
Collapse
X
-
Tags: None
-
Hello Trader_Mark,
Thanks for your post.
When you use Calculate.OnEachTick, the strategy code is executed on each and every tick. In this mode, what can happen (depends on the volatility of the instrument at that moment) is that the entry conditions can be true on one tick, then false, then true and so on and so on. For example, the entry condition on one side is:
if(Close[0] > ema1[0] && Position.MarketPosition == MarketPosition.Flat) So if the close price is greater than the EMA then an order will be placed. The purpose of Position.MarketPosition == MarketPosition.Flat is to only place orders in a flat position. For the MarketPosition to change, the order must be transmitted to the exchange/broker, accepted and then working status returned to the strategy which takes time and in this case more time than subsequent ticks.
You can modify the code to prevent re-entry on the same bar by saving the bar number of the entry and then checking to make sure that on subsequent ticks that the bar number is not the same. If it is the same bar then the entry would not be made. For example, assume you have declared an integer variable called saveBar, using the above code:
if(Close[0] > ema1[0] && Position.MarketPosition == MarketPosition.Flat && CurrentBar != savedBar)
{
EnterLongStopMarket(smaUp[0] + TickBreakLong * TickSize);
SetStopLoss(CalculationMode.Price, smaDn[0]);
savedBar = CurrentBar; // save the bar number to prevent re-entry until a new bar
}
In the above example if the close is greater than the EMA and if the position is flat and is the CurrentBar is not the savedBar, then place the order, set the stoploss and save the bar number that the order was placed on.
You could also modify the other side as well but may want to use a different integer variable.
Reference: https://ninjatrader.com/support/help...currentbar.htm
Alternatively, you can use Calculate.OnBarClose and use the strategy parameters of TickBreakLong and TickBreakShort as these parameters add/subtract the amount of ticks specified to/from the Entry stop market order which would help prevent the original issue.Paul H.NinjaTrader Customer Service
-
Thank you Paul.
Could you link more information about TickBreakLong and TickBreakShort? Searching the NT8 Help Guide does not return any results for those parameters.
Comment
-
Hello Trader_Mark,
Thanks for your reply.
TickBreakShort and TickBreakLong are parameters within the strategy that are exposed in the user interface for you to be able to adjust before running the strategy. These are variables created for you to adjust the strategy.
Please see attached.Paul H.NinjaTrader Customer Service
Comment
-
My bad. I know what those are but when you mentioned them I was thinking more NT symbols and not something in the strategy. Sorry for that.
Comment
-
Next issue - what would cause this stop loss order to get cancelled while in a trade?
A long trade was entered and the stop placed/accepted and then immediately the stop order was cancelled while the original position remained open.
Lastly, is there a trick to seeing the entire row in the log window besides hovering over it?
Comment
-
Hello Trader_Mark,
Thanks for your post.
To see all of the fields you would need to widen the window of the control center and/or change each column width to better fit the information. the grid is like a spreadsheet so you can place your cursor in the column header to change the width by left click and drag on the column lines. It can be a bit tricky as it will auto-adjust other columns as well. You can also move column sequence by left click on the column name and dragging left or right. Finally, you can right mouse click on the grid and select "properties" where you can select or unselect columns to display as well as change the font size.
Regarding the order, please send an e-mail to PlatformSupport[at]NinjaTrader[dot]Com. Mark the e-mail Atten:Paul and include a link to this thread. In the e-mail please attach your log and trace files. In the e-mail advise the name of the strategy and the approximate time of the order (as it is not visible in your screenshot).
Please follow the steps below to manually attach your log and trace files to your e-mail.
Open your NinjaTrader folder under My Documents.
Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
Send the 2 compressed folders as attachments to the email.
Once complete, you can delete these compressed folders.Paul H.NinjaTrader Customer Service
Comment
-
I've run into a nearly identical problem to this on one of the strategies I built for myself would changing it to Calculate on Price change solve this problem without being so crude as to have to go to the end of a bar?
Originally posted by NinjaTrader_Paul View PostHello Trader_Mark,
Thanks for your post.
To see all of the fields you would need to widen the window of the control center and/or change each column width to better fit the information. the grid is like a spreadsheet so you can place your cursor in the column header to change the width by left click and drag on the column lines. It can be a bit tricky as it will auto-adjust other columns as well. You can also move column sequence by left click on the column name and dragging left or right. Finally, you can right mouse click on the grid and select "properties" where you can select or unselect columns to display as well as change the font size.
Regarding the order, please send an e-mail to PlatformSupport[at]NinjaTrader[dot]Com. Mark the e-mail Atten:Paul and include a link to this thread. In the e-mail please attach your log and trace files. In the e-mail advise the name of the strategy and the approximate time of the order (as it is not visible in your screenshot).
Please follow the steps below to manually attach your log and trace files to your e-mail.
Open your NinjaTrader folder under My Documents.
Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
Send the 2 compressed folders as attachments to the email.
Once complete, you can delete these compressed folders.
Comment
-
Hello Daryl Haaland,
Thanks for your post.
Without some level of detail, it would be difficult to advise.
You are of course also welcome to write into PlatformSupport[at]NinjaTrader[dot]Com with the detail (screenshots, code) needed to explain what the issue is and how it presents itself.Paul H.NinjaTrader Customer Service
Comment
-
Here is a screen shot and I'll send a copy of my latest iteration of code directly to you through platform support. It seems to be exiting the market and immediately re-entering the market every time price moves. The strategy is painting dots where I told it to also place the trailing stop, which is based on the "Volatility stop" indicator. so if that's the case it isn't simply being refused due to the placement of the stop location. But could it be an error due to the variables being written with an int value of 0? My next experiment in trouble shooting this problem was going to be re-writing those variables with a value of 9999 both positive and negative in each of 4 combinations.
But at this point really, I'm just guessing.
Originally posted by NinjaTrader_Paul View PostHello Daryl Haaland,
Thanks for your post.
Without some level of detail, it would be difficult to advise.
You are of course also welcome to write into PlatformSupport[at]NinjaTrader[dot]Com with the detail (screenshots, code) needed to explain what the issue is and how it presents itself.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by inanazsocial, Today, 01:15 AM
|
1 response
6 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by rocketman7, Today, 02:12 AM
|
0 responses
10 views
0 likes
|
Last Post
by rocketman7
Today, 02:12 AM
|
||
Started by dustydbayer, Today, 01:59 AM
|
0 responses
2 views
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
23 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
Comment