Is there any point devising strategies and backtesting when the real world trades and results bear no resemblance whatsoever to them, I am using the below code, have run it for 10 days linked to IG. The orders it takes are losing ones, and have no correlation to what the backtesting said it would:
//-------------------------------------------------------------------------
// Main code : RapidReturn WTIv3
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Main code : RapidReturn WTIv3
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Main code : RapidReturn WTIv3
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//TDI OIL Brent Crude (5Min) Alpha Commodities
//
//-------------------------------------------------------------------------
// code-Parameter
DEFPARAM CumulateOrders = false
//Default position size =1
PositionSize = 2.2
timeframe(1 hour, updateonclose)
myrsi = rsi[13]
indicator4, ignored, ignored = CALL "MetaScore"[80, 0, 0](close)
c3 = (indicator4 < 70)
c4 = (indicator4 > 23)
buycondition = myrsi > 15
sellcondition = myrsi < 63
//TDI indicator
//parameters :
//orders management on the 1 minute timeframe
timeframe(5 minute, default)
lengthrsi=13
lengthrsipl=2
lengthtradesl=7
//overbought and oversold values of the TDI indicator
upperzone = 55
lowerzone = 2
//upperzone = upz
//lowerzone = loz
//heiken ashi
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
xHigh = Max(xOpen, xClose)
xLow = Min(xOpen, xClose)
endif
//indicators
r = rsi[lengthrsi](close)
mab = average[lengthrsipl](r)
mbb = average[lengthtradesl](r)
yellowMA = average[5](TypicalPrice)
yellowMAshifted = yellowMA[2]
//trade conditions
longCondition = mab crosses over mbb AND mab<50 AND xHigh>yellowMAshifted AND buycondition AND c3
shortCondition = mab crosses under mbb AND mab>52 AND xLow<yellowMAshifted AND sellcondition AND c4
Longsell=mab crosses under mbb AND mab<upperzone and mab>56 AND xlow>yellowMAshifted
Shortexit= mab crosses over mbb AND mab>lowerzone and mab<56 AND xhigh>yellowMAshifted
//Longsell=mab crosses under mbb AND mab<upperzone and mab>55 AND xlow>yellowMAshifted
//Shortexit= mab crosses over mbb AND mab>lowerzone and mab<58 AND xhigh>yellowMAshifted
//Longsell2=mab crosses under lowerzone
//Shortexit2=mab crosses over upperzone
//***************************
// open position
// long
IF Not LONGONMARKET AND longcondition THEN
BUY PositionSize CONTRACT AT MARKET
ENDIF
// short
IF Not SHORTONMARKET AND shortCondition THEN
SELLSHORT PositionSize CONTRACT AT MARKET
ENDIF
// close position
IF LONGONMARKET and Longsell then//or longsell2 THEN
SELL AT MARKET
ENDIF
IF SHORTONMARKET and Shortexit then//or shortexit2 THEN
EXITSHORT AT MARKET
ENDIF
MyATR = AverageTrueRange[14](close)
//SET STOP LOSS MyATR * 2
//Can use ATR loss for lower risk
//SET STOP PLOSS 65
// SET TARGET PROFIT "value"
p = 165
SET TARGET PPROFIT (p) //395
//SET STOP ploss 230
FYI
Attached is a non-exhaustive list of the elements that can impact a live trading strategy and create differences with a demo account and/or backtests, I’ve highlighted in bold the truest similarities to this particular strategy.
- Spread
- Slippage
- Orders rejections due to one of the above reason, but also because of the allowed distance from current price to put pending orders (known as “minimal distance”)
- Different trading hours (ProOrder code launched in a different time zone / custom hours, by the user)
- Coding problem: division by zero error, null or negative periods for indicators, ..
- Lack of responsiveness of IG demo servers (if IG is the broker), although this has improved considerably since last year.
- Make backtests without tick-by-tick option
- “set stop trailing” instruction that give IG the total control of your stoploss, can be moved differently between accounts due to points above
- Limited risk accounts and their rules
- Guaranteed stoploss rules and fees
- Starting a strategy at a different time (1 hour or even 1 minute later): depending on the code of the strategy, the results of some calculations could be different.
- Margin required on the trading account (no demo or backtest tests are made on this subject)
- Overnight and overweekend fees
- Automatic adjustement of stop orders checked or not when launching the ProOrder
- Minimal distance used in backtests for pending orders, not the same as in real trading, due to broker requirement
- Different contract size between backtests and live
Because backtests are only tested on history *with no connection to live market* , you may encounter differences with real live trading environment subject to spread enlargement, slippage, etc.
Prior to setting my strategy live it had never had such a losing streak as this – something fishy is going on on IG’s side and it isn’t just slippage. How could so many strategies that show as winning in backtesting be bankrupting all users? The coding behind their side is very opaque and for all we know, they are profiteering massively on the backs on PRT users
I sympathise and smile at same time; your thoughts echo same as many of us have had at some stage.
First off, are you 100% sure you had tick by tick enabled when you backtested?
I’ll run your code on my Platform and see if I have moree to add later.
To run your code myself, I would need the Indicator MetaScore and, as I can’t see it in the Library, I take it you bought off MarketPlace?
If Yes, does the Vendor have any comments to alleviate your frustration?
Yes, I found MetaScore Indicator on MP … sounds good, a confluence score of many Indicators!?
Position size of orders in your IG statement is not the same as the one from your backtest, maybe that’s related:
- change position size with 1 for example
- make sure you have sufficient margin required
- check orders list rejection in the platform
- check in ProOrder that these IG statement orders were really launched by the code?
Thank you both for your kind sympathy and input – I think this is more about whining than not winning. I do recommend Metascore, will keep trying and keep all of your advice in mind