This simple strategy is a LONG only. It enters the market when the modified SHARPE index crosses definitely above 1 (I used 1 to cut false signals but 0 could work just fine) and exits in one of the following cases:
1. price crosses below SMA256
2. when, at a trimester check, SHARPE index is not anymore above 1
3. after one year of investment
It works best with 20-30 stocks portfolios, so this strategy should be launched on a selection of stocks.
Blue skies!!
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
//n=1
//p=254
// Condizioni per entrare su posizioni long
idx, ignored = CALL "Mio - indice di Sharpe PRT"[254]
sma254=average[254](close)
lim=n*5*1.1
c1=summation[5](idx)>lim
c11=close>sma254
IF c1 and c11 THEN
BUY 10000 CASH AT market
ENDIF
c3=longonmarket and (barindex-tradeindex)>p
c4=close crosses under sma254
c5=longonmarket and (barindex-tradeindex)>66 and (barindex-tradeindex)<71
c6=longonmarket and (barindex-tradeindex)>130 and (barindex-tradeindex)<135
c7=longonmarket and (barindex-tradeindex)>196 and (barindex-tradeindex)<201
IF c3 then
SELL AT market
ENDIF
if c4 then
sell at market
//sell at low*0.99 stop
endif
if (c5 or c6 or c7) and (summation[5](idx)<lim) then
sell at market
endif
You must be logged in to post a comment.
Dani, questo e' un sistema di investimento (non trading) o buy and hold come qualcuno lo chiama. Entri lungo quando l'indice di Sharpe supera il valore di 1 (ma va bene anche 0 - trovo che uno lavori meglio come filtro) e tieni il titolo per un anno. Ho aggiunto anche altre due possibili uscite. La prima e' quando il valore del titolo scende sotto la SMA254 (media mobile semplice a 254 periodi) e la seconda e' quando il titolo dopo tre mesi non e' piu' sopra il valore 1 dell'indice di Sharpe. In realta' questa sarebbe una strategia da seguire usando solo l'analisi finanziaria ma ho cercato di adattare (per quel poco che e' possibile) il sistema anche per coloro che preferiscono l'analisi tecnica. Gabriele
Hi Gabri, below code buy sell optimized with money management on DAX 4H. Thank's. //------------------------------------------------------------------------- // Code principal : mio - sharpe DAX 4h //------------------------------------------------------------------------- // Definizione dei parametri del codice DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate // Money Management Equity = 500+(StrategyProfit*3) Risk = 0.1 n = Max(1,Equity*Risk/51/PipValue) // ------------ Losses = positionperf(38)>0 Wins = positionperf(38)limh c11=close>sma1 c2=summation[4](idx)<limb c21=closep c4=close crosses under sma1 c5=longonmarket and (barindex-tradeindex)>8 and (barindex-tradeindex)<52 IF c3 or c4 or (c5 and (summation[5](idx)p c7=close crosses over sma2 c8=shortonmarket and (barindex-tradeindex)>8 and (barindex-tradeindex)limb)) then EXITSHORT AT market ENDIF // Stops et objectifs SET STOP %LOSS sl SET TARGET %PROFIT tp
Hi Gabri, thanks a lot for this code and for all the others you already shared with us :) I think there would be an error in line 31? about the indicator and its limit, if you want to test if the indicator is under the limit for the last 5 periods, the code should be: summation[5](idx < lim)=5 But I may be wrong?
Dimenticavo, i titoli che performano meglio sono quelli che crossano la linea dello zero (o dell'uno se vuoi essere sicuro) ma che arrivano da un price to book (P/B) basso. Io seleziono quasi tutti i miei titoli usando il P/B e il P/E e poi, tra quelli che ho filtrato in questo modo, applico le mie strategie.