System improved with management of entry errors
(inserted code where close should be < or > Sar)
low frequency on market (on daily data) but secure
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Costruzione di indicatore di volatilità sulla base di Enrico Malverti, “Dynamic Breakout” in “trading system vincenti”
histvol=STD[n](CustomClose)
// default n = 20 (or in optimization from 18 to 25)
delta=(histvol – histvol[1])/histvol[1]
// entrylong = el
// entryshort = es
el = customclose * (1 + delta)
es = customclose * (1- delta)
isar = SAR[0.02,0.03,0.16]
// Condizioni per entrare su posizioni long
c1 = (el CROSSES OVER es)
c2 = (close >= DClose(1))
c22 = (close > isar)
IF c1 AND c2 and c22 THEN
BUY 2 SHARES AT MARKET
ENDIF
// Condizioni per uscire da posizioni long
indicator5 = SAR[0.02,0.03,0.16]
// could be optimized
c4 = (close < indicator5)
IF c4 THEN
SELL AT MARKET
ENDIF
// Condizioni per entrare su posizioni short
c5 = (es CROSSES OVER el)
c6 = (close <= DClose(1))
c66 = (close < Isar)
IF c5 AND c6 and c66 THEN
SELLSHORT 2 SHARES AT MARKET
ENDIF
// Condizioni per uscire da posizioni short
indicator8 = SAR[0.02,0.03,0.16]
c7 = (close > indicator8)
IF c7 THEN
EXITSHORT AT MARKET
ENDIF
// Stop e target, to be optimized
// lo = from 2 to 4, step 0.5
// pr = from 4 to 8 step 0.5
SET STOP %LOSS lo
SET TARGET %PROFIT pr