Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
FORWARD Testing Problem
Collapse
X
-
Hello,
Thank you for the question.
I will try this and see if I get the same as you are, can you please tell me what instrument / chart settings / strategy settings you are using to get this result?
Also you can test this on your end using TraceOrders http://www.ninjatrader.com/support/h...ub=traceorders
If you enable TradeOrders and open the Tools -> OutputWIndow you can see the lifetime of each order and the events that happen while the strategy is processing. This is greatly helpful for these types of situations if you are unsure why the strategy is having rejections.
I look forward to being of further assistance.
-
I have tried it on GBP/JPY and EUR/USD, this was G/J Renko
World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
I tried the traceroute thing. but I have NO idea what Im looking for. so if u can please look at the code and see if u see anything wrong. I'd appreciate it.
Comment
-
Hello,
Thank you for the image.
Based on what is happening and looking at the code, this is most likely caused by the order in which you are doing your events.
I see that you currently have:
if(Position.MarketPosition == MarketPosition.Short)
{ ExitShort(); }
GoLong();
I am not positive this is the cause as I have not seen this on my end yet, but if this condition were to be true, you would exit a position, then the GoLong() would try to exit and enter a position at the same time because this would be in the same OBU call.
The EnterLong or EnterShort will automatically exit a position in the opposite direction, If you call ExitShort followed by EnterLong, this would not give the strategy time to update the position, in numbers we would see the following:
Lets assume you are Long 1
1
ExitLong 0
EnterShort -2 (this exited the already exited position because these were called at the same time.
If these events happened at the same time you would be trying to modify an order that is no longer there. Essentially this is not giving the OnBarUpdate call time to complete and update your position to the strategy. In general you would want to ensure that only one enter or exit statement is called per one OnBarUpdate call because this gives the strategy time to update your position for your calculations.
Because you are seeing this on your end, you may try to add an else statement to prevent these from happening at the same time. You will need to try this and see if your logic stays correct to what you are going for.
Please let me know if I may be of additional assistance.Code:if(Position.MarketPosition == MarketPosition.Short) { ExitShort(); } else { GoLong(); }
Comment
-
So I changed the code to look like this:
and I'm getting an Error. that says: " Unable to change order ' ' since new limit price is greater/equal ask price or smaller/equal bid price affected Order: Sell 2000 Limit @ 183.681Code:if (CurrentBar < 5) return; EntryHandling = EntryHandling.UniqueEntries; //BUY ENTRY: if( (Position.MarketPosition != MarketPosition.Long) && FirstTickOfBar && (Close[3] < Open[3]) && (Close[2] > Open[2]) && (Close[1] > Open[1])) { GoLong(); DrawArrowUp("My Up arrow" + CurrentBar, false, 0, Low[0] - 3 * TickSize, Color.Gold); } //SELL ENTRY: High Volume and Higher Wick than Previous bar, and Momentum (Waterfall) was Upward if( FirstTickOfBar && (Position.MarketPosition != MarketPosition.Short) && (Close[3] > Open[3]) && (Close[2] < Open[2]) && (Close[1] < Open[1])) { GoShort(); DrawArrowDown("My down arrow" + CurrentBar, false, 0, High[0] + 3 * TickSize, Color.Gold); } }
any idea whats wrong now. and THank you so much for that input, it at least is taking the orders now.
Comment
-
Hello,
I tried this on a 1 tick renko and did get the error.
The error I was receiving was two separate items.
The first I see that some of the orders being submitted are not at valid prices because of the fast market. Essentially you have your price and submit the order but the price has already moved and the order is being submitted on the wrong side of the market. This would be the case in a very fast market on such a small increment chart. To resolve this generally you would need to increase the distance you are placing the order from the current price or move to a higher time chart that has less price action.
The second error is the can not modify order error. This is also happening because of the fast market and also the logic being used.
What is happening is that in the fast market, your exit is being called multiple times and is trying to exit a position that is no longer valid.
Again this is being caused by the logic of how you are entering and exiting. An exit will close the open position but so will your Enter statement, if the condition for these two separate events can happen in One call to OnBarUpdate it will generate an error because you are modifying a position that has already been modified.
For this I would recommend picking a type of chart you want to run this on, such as a renko and pick a set value for now, I am not sure if you will be using 1 as the default value but it seems this will not work with the current logic, I was not getting this in higher values because there is less price action to cause this type of error.
Once you have a set chart type and value to test on you can work through the logic to make sure this is working. Again because you are using CalculateOnbarClose = false and also calling Exit and Enter in the same OnBarUpdate call, you will need to go back through your logic and ensure these two calls happen in two OnbarUpdate calls and not one.
OnBarUpdate needs to complete if you change the position before calling another order logic method, the strategy position will be updated after each OnBarUpdate call so if you exit and enter in the same bar this will not have the correct position for the second call.
I look forward to being of further assistance.
Comment
-
For the question on the EMA,
Lets work through the original question first and then move on to other items. It is difficult to assist when the script in question is being changed during the diagnosis of what is happening. This throws extra variables into the problem and could possibly change the initial inquiry completely.
We will look into what your script is after you have made changes to correct the original question. Based on the code at that point we can see how to accomplish your next task.
I look forward to being of further assistance.
Comment
-
Okay. thanks for help. so Far. On Renko 3 or 4 tick charts. the error hasn't Occured. I got rid of all the code u told me. about Exit() .
Now If you get a chance. I would like to know how to Fix the Stop Loss thing. so that It can automatically trail and only Close a trade on other Side of an EMA (10).
Please.
Thank you
Comment
-
Hello,
If you wanted to use SetStopLoss dynamically instead of statically you would actually do exactly what you are now but you would need to add another condition that checks the EMA Crossover.
You would need to create a crossover condition for the EMA and inside this condition call SetStopLoss using the same signal name as the original SetStopLoss call. This will update the existing order.
We have an example of this located here: http://www.ninjatrader.com/support/f...ead.php?t=3222
I look forward to being of further assistance.
Comment
-
Hey thank you for your support. I left it running for a hour or so. I've Uploaded the Updated Version. and it's working fine on most. except it still Exits unexpectedly gives the error and disables itself.
But the Main problem I'm Having is that it is Taking Orders in Same direction while Its already in a trade. and before you say it: I've already set "Entries per direction" to 1.
In the COde I made sure that it Only Enters Trades If PositionMarketPosition != MarketPosition.Long or short. as you'll see in the code. and its still entering 3000 more contracts in Same direction.
What else can I do to Stop This. I only want it to enter 3000 LONG, and NOT enter until that trade is completely ClosedAttached Files
Comment
-
Any Updates on this last question?
I'd really appreciate a little more help on this. Program still entering too many orders. and I've tried this on GBP/USD and GBP/JPY, AUD/USD, EUR/USD, USD/JPY. different Renko sizes. and stillHey thank you for your support. I left it running for a hour or so. I've Uploaded the Updated Version. and it's working fine on most. except it still Exits unexpectedly gives the error and disables itself.
But the Main problem I'm Having is that it is Taking Orders in Same direction while Its already in a trade. and before you say it: I've already set "Entries per direction" to 1.
In the COde I made sure that it Only Enters Trades If PositionMarketPosition != MarketPosition.Long or short. as you'll see in the code. and its still entering 3000 more contracts in Same direction.
What else can I do to Stop This. I only want it to enter 3000 LONG, and NOT enter until that trade is completely Closed
Okay. this makes NO sense. at times the strategy will run on one chart with no problem. but then out of no where a slight fast move and it'll crash with the Order rejection thing. Is there anything that I can ADD to the Code or change the way the Stops are placed to fix this. I'm at a Total lost here. Please help.Last edited by ginx10k; 02-20-2015, 08:00 AM.
Comment
-
Hello,
Thank you for the questions.
I looked this over this morning and I still believe this is being caused by the order in which you are doing your logic.
For your entries there is no check to see if you are in a position currently so they can try to submit on every tick that your condition is true. You have specified to use CalculateOnbarClose = false so this logic is happening multiple times per bar.
I added
Around the EnterLong and EnterShort statements, for what you are currently doing these calls are only needed when you are flat as you are controlling the stops and profit targets that are associated. Being that the logic is called multiple times per bar, if the condition that controls the stops is true and one of the stops or profit targets gets filled the EnterShort or EnterLong can then run which could create an overfill because the position has not yet been updated.Code:if (Position.MarketPosition == MarketPosition.Flat) { }
After adding the above code this has prevented the overfill because it no longer can submit unless your position has been updated.
I look forward to being of further assistance.
Comment
-
I def will try that. but I did have some logic in the code I posted it. didn't u see it? http://content.screencast.com/users/...ce/sample2.png
I'm going to change it. and give it a go for a few hours. The reason I had market position as Long/SHort in the condition is cause I wanted the Trades to Reverse if the condition was met. and I did add FirstTickOfBar, so shouldn't that have helped.?
Do you think it would be better to change the whole strategy to CalculateOnBarClose = true; would it still submit the stop orders limits in time? I don't know how that works.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
650 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
577 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment