// Definizione dei parametri del codice
DEFPARAM CumulateOrders = true // Posizioni cumulate attivate
// Condizioni per entrare su posizioni long
indicator1 = call "media triang + diff 2 medie"[4, 14, 63]
c1 = (indicator1[1] CROSSES UNDER indicator1[2])
indicator3 = CALL "media triang + diff 2 medie"[13, 280, 365]
short = (indicator1 [1] < indicator3[1])
long= (indicator1 [1] > indicator3[1])
maxshares= COUNTOFLONGSHARES <=5 //10minifib 5 sp500
longdistance= close [1]< (TRADEPRICE-(70*pointsize))//71 ftsemib 6.75 sp 500
exitdistance= close [1]> (TRADEPRICE+(70*pointsize))//70
if not onmarket and short and exitdistance then
buy 1 shares at market
endif
IF c1 AND short and maxshares and longdistance then
BUY 1 SHARES AT MARKET
ENDIF
// Condizioni per uscire da posizioni long
indicator4 = CALL "media triang + diff 2 medie"[4, 14, 63]
indicator5 = CALL "media triang + diff 2 medie"[4, 14, 63]
c3 = (indicator4[1] > indicator5[2])
IF c3 and long and exitdistance THEN
SELL 1 shares AT MARKET
ENDIF