ProOrder backtest opens trade late
Forums › ProRealTime English forum › ProOrder support › ProOrder backtest opens trade late
- This topic has 17 replies, 5 voices, and was last updated 6 years ago by Nicolas.
-
-
01/09/2018 at 4:47 PM #58690
Hello, I’m BackTesting with some Exponential moving averages, and the backtest often opens a trade a candle or 2 after the first candle after the EMA cross. Making the results inaccurate. Using a slightly faster EMA to compensate is what I’ve been doing, but that creates other problems.
My code is very basic and is just calculating EMA on the close of the candle, and so is my indicator on the chart. So nothing wrong there.
Attached is an example.
Any ideas on how to fix this?
01/09/2018 at 5:13 PM #58695If you actually just have the 2 averages that constitute your signal we might be able to see exactly what you are describing but with 4 averages i am clueless to what you are actually describing ? Ambiguity isnt helping here , Clarity makes it much easier …
01/09/2018 at 5:20 PM #58698You should post your complete code for anyone to be of help.
Roberto
01/09/2018 at 5:39 PM #5870501/09/2018 at 5:48 PM #58709- A cross between 2 lines is confirmed at Close
- Code is read at Close and orders are launched at next bar Open
which in effect is a lag of what really should be 1 tick .
a signal during bar is useless thats why it is done this way , only once a bar is complete can a signal truly be verified
01/10/2018 at 12:57 AM #58778Hi, here’s my code. It’s very basic, so hopefully theres nothing wrong there.
123456789101112131415EMA1 = ExponentialAverage[25](close)EMA2 = ExponentialAverage[100](close)cBuy = (EMA1 crosses over EMA2)cSell = (EMA1 CROSSES under EMA2)set stop %loss 0.5IF cBuy THENBUY 1 Contract AT MarketENDIFIF cSell THENSELLSHORT 1 Contract AT MarketENDIF01/10/2018 at 1:17 AM #5878001/10/2018 at 1:18 AM #58781So to get ProOrder to execute when I want it, should I change by indicator/code to calculate on the open instead of the close? Because when I do so, it still opens the trade ‘late’.
The pictures attachted are with the code calculating the EMA on ‘open’ instead of ‘close’
01/10/2018 at 1:20 AM #58782You need to move your set stop %loss 0.5 down to the last line of code. Code is read from top to bottom at the close of each candle and so you will have to wait for a candle to pass after opening trades before it is read. At the bottom below the buy/sells it will put an order to the market just after buying or selling.
01/10/2018 at 1:24 AM #5878501/10/2018 at 9:48 AM #58798No all decisions are made at the close of a candle and new position are opened at the open of the next – so be aware of markets with big gaps!
The only way to open a position mid candle is to set market stop and limit orders at a chosen price but these orders will once again not be placed until the current candle has closed.
01/10/2018 at 10:19 AM #5880501/10/2018 at 11:06 AM #5881201/10/2018 at 11:11 AM #58813I get that, but in my case I dont want to open mid candle as soon as the EMAs cross, I want to open on the open of the first candle after the cross happens. This works fine in real time trading since the EMAs move, visually, on the open of a new candle(even if counting from ‘close’) but it backtesting they work differently it seems.
01/10/2018 at 11:22 AM #58814I dont want to open mid candle as soon as the EMAs cross, I want to open on the open of the first candle after the cross happens.
When a candle closes PRT will just check that a cross has occurred at that point in time (I guess it just compares the MA positions from this close to the previous close). It then opens a position at the next open. So it is doing what you want. I have to confess that I am struggling to see the problem at the moment 🙂
-
AuthorPosts
Find exclusive trading pro-tools on