if barindex > 0 then
xClose = (open+close+low+high)/4 //TotalPrice
xOpen = (xOpen[1]+xClose[1])/2
//haHigh = Max(xOpen, xClose)
//haLow = Min(xOpen, xClose)
//xHigh = Max(High,haHigh)
//xLow = Min(Low,haLow)
//xRange = abs(xClose - xOpen)
else
xClose = (open+close+low+high)/4 //TotalPrice
xOpen = (Open[1]+Close[1])/2
//haHigh = Max(xOpen, xClose)
//haLow = Min(xOpen, xClose)
//xHigh = Max(High,haHigh)
//xLow = Min(Low,haLow)
//xRange = abs(xClose - xOpen)
endif
Rialzista = xClose > xOpen
Ribassista = xClose < xOpen
Media = average[200,0](xClose)
Rialzo = Rialzista AND Ribassista[1] AND xClose > Media //cambio colore candela e Prezzo sopra Media200
Ribasso = Rialzista[1] AND Ribassista AND xClose < Media //cambio colore candela e Prezzo sotto Media200
IF Rialzo AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF Ribasso AND Not OnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
SET STOP pLOSS 50
SET TARGET pPROFIT 200