Writing codes and testing them is a very good educational tool
I agree, a good point well made (as usual) but I do think that newbie (or not so newbie coders can get sucked in by the optimiser and it can take a long long time coding, backtesting, demo running to understand the clear signs of curve fitting. Maybe the Topic Aloysius proposed might shorten the learning curve.
I’ll put my hand up and say the Optimiser sucked me in for long enough … and I understood about curve fitting and the signs … hell it still sucks me in especially after many hours coding! I think because I want to see results / some £££s for my time and so I launch a System (sometimes even in Live) and then wish I never had! 🙂
Hey we should start new Threads on these interesting Topics under Trading Discussions?? It would mean we don’t hijack Threads on the coding Support Forum? Apologies readers!
I think the main problem of most of the strategies here is that they are optimized over the whole available data. One must understand that this is just producing fantasy results. Either WFA or at least an OOS test is absolutely mandatory for having a result that is somehow useful. I pointed out so several times to Reiner but he always replied that he had no time to do so.
BTW I agree that we should start a new thread. This discussion is not really a pathfinder discussion anymore.
and so I launch a System (sometimes even in Live) and then wish I never had!
I never put a strategy live straight away – I need to build confidence in it first. I am very very cautious about putting any code live (at the moment I have exactly zero codes running live while I wait for the markets to sort themselves out and get rid of all the noise we currently have).
I am actually very happy if a strategy fails in demo. First of all I have lost no money (half the battle is won) and secondly I can re-analyse the strategy and work out why it went wrong – which is a free lesson in how not to do it.
I have create a new topic to talk about codes “one year after”.
Hello guys, maybe i’ve found a new way to filter the strategy, here is the result for now, what do you think?
(the multiplier and the position size are the same)
[attachment file=67079]
Pls, can you put the code in here or give as attachment?
Pls, can you put the code in here or give as attachment?
Sure, at the beginning i was jelous of it, but in this forum i found so much help and new idea that i want to share mine too!
I hope we can work on it ad see if these could help us!
////FILTRI long
ONCE LL = -160
ONCE SS = 26
//once mioL = var
//filtri short
once AA = -140
ONCE BB = 55
mac= MACDline[12,26,9](close)
ONCE P = 5
ONCE COEFF = 0.7
///codici filtri
REM Calcolo della Media Mobile
MME3 = ExponentialAverage[P](ExponentialAverage[P](ExponentialAverage[P](close)))
MME4 = ExponentialAverage[P](MME3)
MME5 = ExponentialAverage[P](MME4)
MME6 = ExponentialAverage[P](MME5)
REM Calcolo dei coefficienti
ONCE c1 = SQUARE(coeff)*coeff
ONCE c1 = -c1
ONCE c2 = 3*SQUARE(coeff)-3*c1
ONCE c3 = -2*c2 -3*c1 -3*coeff
ONCE c4 = 1 + 3*coeff + c2 +2*c1
Tilson = c1*MME6 + c2*MME5 + c3*MME4 + c4*MME3////////////
c02=R2[50](Tilson)-r2[50](average[50])
filtrolong= (mac > LL) and (mac < SS) and (c02 < 0.03)and (c02>-0.49)//and c1//AND ff2 and c1 //AND ff3
filtroshort= (mac > AA) and (mac < BB) //and c2// and ss1 and c2// AND ss2
order section need to be changed in
// long entry with order cumulation
IF ( l1 OR l4 OR l2 OR (l3 AND f2) ) AND NOT alreadyReducedLongPosition THEN
// check saisonal booster setup and max position size
IF saisonalPatternMultiplier > 0 THEN
numberContracts = MAX(1, MIN(maxPositionSizePerTrade, positionSize * saisonalPatternMultiplier) * scaleFactor)
IF (COUNTOFPOSITION + numberContracts) <= maxPositionSizeLong * scaleFactor THEN
IF SHORTONMARKET THEN
EXITSHORT AT MARKET
ENDIF
if filtrolong then
BUY numberContracts CONTRACT AT MARKET
ENDIF
endif
ELSIF saisonalPatternMultiplier <> 0 THEN
numberContracts = MAX(1, MIN(maxPositionSizePerTrade, positionSize) * scaleFactor)
IF (COUNTOFPOSITION + numberContracts) <= maxPositionSizeLong * scaleFactor THEN
IF SHORTONMARKET THEN
EXITSHORT AT MARKET
ENDIF
if filtrolong then
BUY numberContracts CONTRACT AT MARKET
ENDIF
ENDIF
ENDIF
stopLoss = stopLossLong
takeProfit = takeProfitLong
ENDIF
// short entry with order cumulation
IF ( (s1 AND f3) OR (s2 AND f1) OR (s3 AND f3) ) AND NOT alreadyReducedShortPosition THEN
// check saisonal booster setup and max position size
IF saisonalPatternMultiplier < 0 THEN
numberContracts = MAX(1, MIN(maxPositionSizePerTrade, positionSize * ABS(saisonalPatternMultiplier)) * scaleFactor)
IF (ABS(COUNTOFPOSITION) + numberContracts) <= maxPositionSizeShort * scaleFactor THEN
IF LONGONMARKET THEN
SELL AT MARKET
ENDIF
IF filtroshort THEN
SELLSHORT numberContracts CONTRACT AT MARKET
ENDIF
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
numberContracts = MAX(1, MIN(maxPositionSizePerTrade, positionSize) * scaleFactor)
IF (ABS(COUNTOFPOSITION) + numberContracts) <= maxPositionSizeShort * scaleFactor THEN
IF LONGONMARKET THEN
SELL AT MARKET
ENDIF
IF filtroshort THEN
SELLSHORT numberContracts CONTRACT AT MARKET
ENDIF
ENDIF
ENDIF
stopLoss = stopLossShort
takeProfit = takeProfitShort
ENDIF
@reiner what do you think?
Would be great if there could be a ‘switch’ that makes max numbercontracts = 1 or 2 or 4 or user choice?
Reason is I always Backtest at Lot Size = 1 and so to compare with other Systems I need Lot size = 1.
I have made changes as below in 4 places and still it is sellingshort at more than 1 on some trades.
Also if I make changes as below then I have to remember where I made the changes if I want it back again as original 🙂
numberContracts = 1 or MAX(1, MIN(maxPositionSizePerTrade, positionSize) * scaleFactor)
@Gianluca, be careful because your code cause positions of 60 lots when winning in the backtest, but in real life it could be very dangerous. Filtering past bad trades does not mean that it will filter future bad ones. It would be wise to watch in demo before live trading.
@gianluca, be careful because your code cause positions of 60 lots when winning in the backtest, but in real life it could be very dangerous. Filtering past bad trades does not mean that it will filter future bad ones. It would be wise to watch in demo before live trading.
I know, but if you can see the 60 lots are after thousand and thousand of gain. In fact the basic size is 1, and the increase is not so fast.
Of course the risk could be changed upon the own risk.
Of course it doesn’t mean that in future will not be bad trades, but we are trying to find a statistics advantage, and we can find it only working on the past.
Yes so if i look at the curve of the backtest, the first time it takes 60 lots (june 27, 2013), the system has won 23000€ : but if the market had unfortunatly fallen for 350 points (which is not exceptional), all the gains were gone. But if this had happen, when backtesting now, optimization would have found other filter variable to avoid this bad trade.
Yes so if i look at the curve of the backtest, the first time it takes 60 lots (june 27, 2013), the system has won 23000€ : but if the market had unfortunatly fallen for 350 points (which is not exceptional), all the gains were gone. But if this had happen, when backtesting now, optimization would have found other filter variable to avoid this bad trade.
[attachment file=67684]
The first big position is on march 28 2012 and was 14 size, in that date the system had also a gain of 3000€ maybe yes is too much, and in a real account is better to put less risk on, i am using it on DEMO, and there there’s no problem with size 😀
PATH 4H DAX V7 (filt) Demo-Mode took yesterday a short postion at 12.284 SL 12.683 TP 11.946
maybe the first trade will be a loss?