I’ve been working on a simple weekly strategy but when I just looked closely at the trade opening and closing positions on the candles I notice that they are shown on the decision candle rather than on the open of the following candle.
In this image the arrows show where I would normally expect to see the positions opened and closed at the opening price of the candle following the candle that decided to open or close the trade.
They do seem to be shown at the correct price when gaps occur between the Friday close and the next weeks opening price just not on the usual candle.
If I switch to daily candles and run the same strategy the opening and closing of trades is shown on the following candle after the decision to open a trade candle had closed which is what I would expect.
This is a little more serious than I first thought. I wrote yet another too good to be true strategy that runs on the weekly chart and so I decided to take a closer look at each candle. I used the following line as a simple test strategy to confirm what I was seeing. It should simply buy if price is hits the last closed candles average[2] (low) level.
1
buy1contractataverage[2](low)limit
I notice that in the backtest it is opening positions based on the value of the average for the currently forming candle rather than the average value for the candle just closed as you would expect. No wonder it is too good to be true! If I change the code to look at the value for the previous candle like this then it is still not correct though:
1
buy1contractataverage[a](low[1])limit
Now at least I get some correct trades but there are trades at prices that were never seen and missing trades completely.
I will move this topic to the Platform Forum as I feel that is where it should be and I will send a report to PRT.
I have found a temporary work around to the last issue by using MTF. I get the entry prices I want from the weekly chart and then trade on the daily chart and limit it to one entry a week. It is not ideal as there has not been a Sunday candle throughout the whole data history so I have to reset my weekly trade flag on the close of Friday which means my exit could be on a Sunday rather than the open of Monday but it is the best I can achieve until this bug is fixed by PRT. Also I cannot trade live with it yet but hopefully by the time I have done a couple of months forward testing MTF will be available on live or the bug will be fixed and I can trade directly on the weekly charts.
Note: The above is another example of why I would like to be able to change the value of a variable in different time frames. I could then reset a buyflag to zero at the end of a weekly candle and then set it to 1 on a daily candle if a trade is opened thus limiting trades to one a week. At the moment I have to do it all in the daily time frame and the end of the week has not always been the same day of the week in the data.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue