I guess there must be a difference but I’ve only ever developed and tested on DFB so not able to be much help. Hopefully someone more experienced will chip in with an answer to the positionsize problem.
I changed the maxpositionsize to 5 (5000 was a stresstest, I could read earlier in this thread).
I changed
set target pprofit TakeProfit
to
set target profit TakeProfit
This is the tick-by-tick results.
Ronny: Cool. Will test tomorrow.
Thanks for that Ronny. It seems that the ATR based Stoploss and TakeProfit although profitable may not necessarily be an improvement on fixed SL and TP levels. Early on there is a big drawdown which is what I always fear with short period ATR based decisions. A big candle can leave you vulnerable with a big stoploss calculated from it. Pity really as markets are changing animals and ATR always seems to be a good way to stay in tune with the market but unfortunately ATR can be too spiky or too laggy depending how fast or slow you set it – just like any MA.
Out of interest how did you decide on the fixed levels for SL and TP that you chose – was it an optimization backtest?
@ronny
in resume, you have this code?
because on backtest, they are a problem
//EURUSD(DFB) – IG MARKET
// TIME FRAME 1H
// PROBACKTEST TICK by TICK
// SPREAD 0.9 PIP
// ALE – KASPER – VONASI
DEFPARAM CumulateOrders = false
CP = 101 //Fractal Period
RSINum = 2
Ave = 7 //AverageTrueRange Period
TGLMult = 0.6 //ATR multipier for TGL
STPMult = 1.8 //ATR multiplier for StopLoss
AddOn = 1.1 //Added to STPMult for TakeProfit
RSIHighLevel = 80
RSILowLevel = 100 – RSIHighLevel
//KASPER CODE OF REINVESTMENT
Reinvest=1
if reinvest then
Capital = 5000
Risk = 1//0.1//in % pr position
StopLoss = AverageTrueRange[Ave] * STPMult
TakeProfit = AverageTrueRange[Ave] * STPMult + AddOn
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = (equity*(Risk/100))
MAXpositionsize=5
MINpositionsize=1
Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(((maxrisk/StopLoss)))))
else
Positionsize=1
StopLoss = AverageTrueRange[Ave] * STPMult
TakeProfit = AverageTrueRange[Ave] * STPMult + AddOn
Endif
///BILL WILLIAM FRACTAL INDICATOR
if Close[cp] >= highest[2*cp+1](Close) then
LH = 1
else
LH = 0
endif
if Close[cp] <= lowest[2*cp+1](Close) then
LL = -1
else
LL = 0
endif
if LH = 1 then
HIL = Close[cp]
endif
if LL = -1 then
LOL = Close[cp]
endif
//CumulativeRSI2
RSI2 = (SUMMATION[RSINum](RSI[RSINum](Close)))/RSINum
RSILow = RSI2 < RSILowLevel
RSIHigh = RSI2 > RSIHighLevel
//LONG and SHORT CONDITIONS
if (time >=100000 and time < 230000) then
C1 = (close CROSSES OVER HIL)
D1 = (close CROSSES UNDER LOL)
IF c1 and NOT ShortOnMarket and RSIHigh THEN
PositionMultiple = (RSI2/100) + 1//Increase PositionSize depending on CumRSI2 level
PositionSize = (PositionSize/((RSIHighLevel/100)+1)) * PositionMultiple
PositionSize = Round(PositionSize * 100)
PositionSize = PositionSize / 100
BUY positionsize CONTRACT AT MARKET
ENDIF
IF D1 and NOT LongOnMarket and RSILow THEN
PositionMultiple = ((100-RSI2)/100) + 1//Increase PositionSize depending on CumRSI2 level
PositionSize = (PositionSize/((RSIHighLevel/100)+1)) * PositionMultiple
PositionSize = Round(PositionSize * 100)
PositionSize = PositionSize / 100
SELLSHORT positionsize CONTRACT AT MARKET
ENDIF
ENDIF
//TRAILING STOP
TGL = AverageTrueRange[Ave] * TGLMult
TGS = TGL
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PriceExit = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PriceExit = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PriceExit = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PriceExit>0 then
EXITSHORT AT PriceExit STOP
SELL AT PriceExit STOP
ENDIF
set target profit TakeProfit
set stop ploss stoploss
@vonasi
I kind of agree with the ATR-way of setting TP and SL. But I feel I lose control with the risk managment, and ususally prefer to use the fixed ones. The values I used in the backtest is from the top of my head at the time. I have now run a WF-test which returned a takeprofit of 50 and stoploss at 75… Every trader has his own risk profile 🙂 The results from the testing of this strategy seems to return too good of values, it’s easy to think overfit. But as I said, the results of live trading a similar strategy returns good results (but not in significant numbers yet).
@rejo007
Yes, there’s something wrong with the reinvest code. I don’t know what.
Thanks for doing that test Ronny. Interesting that your off the top of your head numbers had higher TP than SL but the WF test gave higher SL than TP. What was the win rate and returns like compared to your numbers? I prefer at least 1:1 Risk to Reward as even by tossing a coin I can be right 50% of the time – although give me a strategy with an almost certain 100% win rate and I’ll obviously take a worse R/R ratio!
Is the strategy that you say you are testing live ALE’s original strategy or another one that you have – if another one would you be able to share it for comparison purposes?
The higher the stoploss is the higher win percentage you will have, as you say. And often much better results. The problem is the DD that will occur, that can wipe us out. I agree with you that RR of 1:1 is minimal. For that reason I’m a bit hesitant to let the optimalization “decide” this values. I’ll try with some values I’ll like to live with, and run OOS without any optimalization. For the TP and SL.
Here’s the code running live since May:
//-------------------------------------------------------------------------
// Main code : PRC - FBS_EURUSD_60M_V2
//-------------------------------------------------------------------------
//EURUSD(-) - IG MARKET
// TIME FRAME 1H
// PROBACKTEST TICK by TICK - 200.000 bars
// SPREAD 0.6 PIP
// ALE
DEFPARAM CumulateOrders = false
DC=20// period of Donchian Stop
TGL=5//Trailing Stop pip distance
TGS=5
TP=30
//SL
IF LONGONMARKET THEN
DC=20// period of Donchian Stop
TGL=5//Trailing Stop pip distance
TP=30//take profit
//SL=50// stop loss
ELSIF SHORTONMARKET THEN
DC=20// period of Donchian Stop
TGS=5
TP=30
//SL=50
ENDIF
//KASPER CODE OF REINVESTMENT
Reinvest=0
if reinvest then
Capital = 10000
Risk = 1//0.1//in % pr position
StopLoss = 40
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
MAXpositionsize=5000
MINpositionsize=1
Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(round((maxrisk/StopLoss)))))//*Pointsize))))
else
Positionsize=1
StopLoss = 40
Endif
///BILL WILLIAM FRACTAL INDICATOR MODIFIED
CPL=80//period of superior fractal level
CPS=100//period of inferior fractal level
if close[CPL] >= highest[2*CPL+1](close) then
LH = 1
else
LH=0
endif
if LH=1 then
HIL = close[CPL]
endif
if close[CPS] <= lowest[2*CPS+1](close) then
LL= -1
else
LL=0
endif
if LL = -1 then
LOL=close[CPS]
endif
//LONG and SHORT CONDITIONS
RL=0 // range long candles
RS=0 // range short candles
if (time >=100000 and time < 230000) then
A1 = (close CROSSES OVER HIL)
A2 = (close CROSSES UNDER LOL)
FL= (CLOSE-OPEN)>=RL*POINTSIZE
FS= (CLOSE-OPEN)<=-RS*POINTSIZE
IF A1 and not shortonmarket AND FL THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
IF A2 and not longonmarket AND FS THEN
SELLSHORT positionsize CONTRACT AT MARKET
ENDIF
ENDIF
//TRAILING STOP
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
// DONCHIAN STOP
f=Lowest[DC](low)
e= Highest[DC](high)
if longonmarket then
laststop = f[1]
endif
if shortonmarket then
laststop = e[1]
endif
if onmarket then
sell at laststop stop
exitshort at laststop stop
endif
SET STOP PLOSS StopLoss
SET TARGET PPROFIT TP
Ronny
Then you have run algon live for 4 months now.
Has it gone as you expected?
In that case you can increase the position size as it looks stable 🙂
The results are in post 48533.
Thanks for sharing that Ronny. It looks very similar to what ALE first posted on this thread except with different fractal look back periods for upper and lower fractals and also with a candle body size condition that is not used. My quick backtest of it shows that it performed better in the past than recently which makes me think it may be a little over fitted. Different periods for upper and lower fractals rings alarm bells for fitting. The fractal period is my major concern with this strategy as it is the most likely thing to be fitted to past market movements. Having said that a wide range of cp numbers result in profit of some sort or other so it does still seem to be a method worth progressing with.
Can I ask where you got that strategy from? Is there an old thread that I missed that I could read?
Tried to optimize usd/chf. Also tried WF with…. average results. Should mention I’m new to using that. Anyway, uploading results if anyone wants to use it.
Very good. Now you start using the WFA tool correctly. This makes it of course much more difficult to create a good strategy but it says so much more as a standard backtest.
Bonjour à tous, Quelqu’un at-il eu la dernière version du code FBS qui fonctionne avec IG PRT.
there are many different version. which is the most optimized? Thank you for your answers
Here is a GBPUSD 15M LONG
version of the strategy (100,000 bars, backtest tick by tick, 2 point spread)
With the reinvestment version with the Kasper code, in my example the risk per position is 2%
Can you tell me what you think?
If somebody would have time to do it with the version 200.000 bars this would be well. thank you