Qualche settimana fa abbiamo dedicato un articolo al Supertrend. Torniamo sull’argomento con un’altra variante sul tema di cui alleghiamo il listato Powerlanguage compatibile con Multicharts e Tradestation ma facilmente codificabile anche in altri linguaggi. Il codice lo scrissi un paio di anni fa solleticato da Alessandro Aldrovandi che utilizza per il suo trading discrezionale Supertrend e vWap, li mettemmo assieme a scopo didattico formando una nuova “ricetta” battezzata da Alessandro “Supervolume” dove le entrate sono date dal Supertrend e le uscite da vWap cui si aggiunge una uscita in stop profit dopo 5 barre dall’ingresso.
Riportiamo i test effettuati all’epoca (nel 2013) sul Dax30 futures a 60 minuti (dati eSignal) mostrando anche la differenza tra equity line lorda di slippage e commissioni ed equity line netta da 35 € di slippage+commissioni a trade.
Messo su una chart ai giorni nostri da inizio anno il listato avrebbe prodotto circa 20 mila € di profitto anche se con una curva dei profitti un po’ volatile.
Come sempre lo spirito di questi articoli non è di fornire una formula pronta all’uso ma una base di studio e di ricerca per appassionati, neofiti e trader avanzati. Molte sono infatti le migliorie che si possono apportare a questa strategia ma occorre sensibilità ed esperienza…
Buono studio e buon trading!!
[LegacyColorValue = true];
vars:
PriceW(0),
ShareW(0),
Count(0),
VolWAPValue(0),
VolWAPVariance(0),
VolWAPSD(0);
if date > date[1] then begin
PriceW = 0;
ShareW = 0;
Count = –1;
Value1 = 0;
Value2 = 0;
VolWAPValue = 0;
end;
PriceW = PriceW + (AvgPrice * (UpTicks+DownTicks));
ShareW = ShareW + (UpTicks+DownTicks);
Count = Count + 1;
Value3 = 0;
if ShareW > 0 then VolWAPValue = PriceW / ShareW;
For Value1 = 0 To Count Begin
if sharew <> 0 then Value2 = ((UpTicks[Value1]+DownTicks[Value1])/ShareW) * (Square(AvgPrice[Value1]-VolWAPValue));
Value3 = Value3 + Value2;
End;
VolWAPVariance = Value3;
Var: volatilita(0),
prezzomediano(0),
bandaup(0),
bandadn(0),
trend(0),
supertrend(0),
colore(0),
inizio(0);
input: Moltiplicatore(2),
Nm_periodi(75);
volatilita = avgtruerange(Nm_periodi);
prezzomediano = (H + L) / 2;
bandaup = prezzomediano + (moltiplicatore * volatilita);
bandadn = prezzomediano – (moltiplicatore * volatilita);
if inizio = 0 then begin
trend = 1;
inizio = 1;
end;
if trend = 1 and
C < bandadn[1]
then Begin
trend = –1;
bandaup = prezzomediano +
(moltiplicatore * volatilita);
supertrend = bandaup;
end;
if trend = 1 and
C >= bandadn[1] and
bandadn < bandadn[1]
then Begin
bandadn = bandadn[1];
supertrend = bandadn;
end;
if trend = 1 and
C >= bandadn[1] and
bandadn >= bandadn[1]
then
supertrend = bandadn;
if trend =-1 and
close > bandaup[1]
then begin
trend = 1;
bandadn = prezzomediano –
(moltiplicatore * volatilita);
supertrend = bandadn;
end;
if trend =-1 and
close <= bandaup and
bandaup > bandaup[1]
then begin
bandaup = bandaup[1];
supertrend = bandaup;
end;
if trend =-1 and
close <= bandaup and
bandaup <= bandaup[1]
then
supertrend = bandaup;
if T >= sess1firstbartime and T < 2000 then begin
if close > supertrend and C[1] < supertrend[1] and marketposition = 0 then buy next bar at open;
if C < supertrend and C[1] > supertrend[1] and marketposition = 0 then sellshort next bar at open;
if marketposition = 1 and C[1] < VolWAPValue[1] and C < VolWAPValue then sell next bar at open;
if marketposition = –1 and C > VolWAPValue and C[1] > VolWAPValue[1] then buytocover next bar at open;
end;
if barssinceentry >= 5 and openpositionprofit>700 then begin
if marketposition = 1 then sell next bar at entryprice+10 stop;
if marketposition = –1 then buytocover next bar at entryprice–10 stop;
end;
Strategy Performance Summary (dal febbraio 1997 al 25 marzo 2013) | |||
All Trades | Long Trades | Short Trades | |
Net Profit | 255435,000000001 | 107389,999999997 | 148044,999999997 |
Gross Profit | 1126162,49999999 | 549802,500000005 | 576360,000000004 |
Gross Loss | -870727,499999994 | -442412,499999997 | -428314,999999996 |
Adjusted Net Profit | 183190,633885308 | 56374,8768348685 | 96593,0810817751 |
Adjusted Gross Profit | 1083748,76650212 | 521334,805643055 | 544728,135556175 |
Adjusted Gross Loss | -900558,132616811 | -464959,928808187 | -448135,054474399 |
Select Net Profit | 104699,999999998 | 72815,0000000078 | 31885,0000000074 |
Select Gross Profit | 677089,999999993 | 342832,500000005 | 334257,500000004 |
Select Gross Loss | -572389,999999994 | -270017,499999997 | -302372,499999996 |
Account Size Required | 41662,4999999995 | 51962,5000000005 | 30730,0000000006 |
Return on Account | 613,1053105311 | 206,6682703873 | 481,7604946306 |
Return on Initial Capital | 255,435 | 107,39 | 148,045 |
Max Strategy Drawdown | -43277,5 | -55225 | -32622,5 |
Max Strategy Drawdown (%) | -25,1884873145 | -25,4994844514 | -17,4235242279 |
Max Close To Close Drawdown | -41662,4999999995 | -51962,5000000005 | -30730,0000000006 |
Max Close To Close Drawdown (%) | -14,4905157667 | -23,1029155135 | -16,5428509905 |
Return on Max Strategy Drawdown | 5,9022586795 | 1,9445903124 | 4,5381255269 |
Profit Factor | 1,2933581402 | 1,2427372644 | 1,3456451443 |
Adjusted Profit Factor | 1,203418999 | 1,1212467427 | 1,2155445777 |
Select Profit Factor | 1,1829172417 | 1,2696677067 | 1,1054494043 |
Max # Contracts Held | 1 | 1 | 1 |
Slippage Paid | 108990,000000003 | 53060,0000000015 | 55930,0000000017 |
Commission Paid | 0 | 0 | 0 |
Open Position P/L | n/a | n/a | n/a |
Annual Rate of Return | 15,816062342 | 6,649390001 | 9,166672341 |
Monthly Rate of Return | 1,3180051952 | 0,5541158334 | 0,7638893617 |
Buy & Hold Return | 150109,511889862 | 146941,612604263 | 150109,511889862 |
Avg Monthly Return | 1316,675257732 | ||
Monthly Return StdDev | 6007,1779950276 | ||
Performance Ratios | |||
Upside Potential Ratio | 32,6094852404 | ||
Sharpe Ratio | 0,1640848886 | ||
Sortino Ratio | 0,218981974 | ||
Fouse Ratio | 0,0052530839 | ||
Calmar Ratio | 0,0088757168 | ||
Sterling Ratio | 0,0019706488 | ||
Net Profit as % of Largest loss | 3544,0166493236 | ||
Net Profit as % of Max Trade Drawdown | 2911,7697349672 | ||
Net Profit as % of Max Strategy Drawdown | 590,2258679452 | ||
Select Net Profit as % of Largest loss | 1452,6534859521 | ||
Select Net Profit as % of Max Trade Drawdown | 1193,5024223425 | ||
Select Net Profit as % of Max Strategy Drawdown | 241,9270983768 | ||
Adj Net Profit as % of Largest loss | 2541,6667899453 | ||
Adj Net Profit as % of Max Trade Drawdown | 2088,2374908556 | ||
Adj Net Profit as % of Max Strategy Drawdown | 423,2930134257 | ||
Time Analysis | |||
Trading Period | 16 Yrs, 2 Mths, 10 Dys, 22 Hrs | ||
Time in the Market | 7 Yrs, 3 Mths, 22 Dys, 21 Hrs | ||
Percent in the Market | 45,1248110529 | ||
Longest flat period | 22 Dys, 23 Hrs | ||
Max Run-up Date | 22/07/98 | ||
Max Drawdown Date | 09/10/08 | ||
Max Strategy Drawdown Date | 28/03/09 | ||
Max Close To Close Drawdown Date | 27/03/09 |
Rinnovo ancora una volta i complimenti per lo sforzo divulgativo dei (preziosi) contenuti.
Grazie, fa piacere che ci sia chi apprezza.