//-------------------------------------------------------------------------
// Codice principale : WALL 6m da provare
//-------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//WALL STREET
// 6 MIN.
DEFPARAM cumulateorders = FALSE
CONDAVG = 1
AVG = Average[S](close)
FOR C = 1 TO F
IF AVG[C-1] > AVG[C] THEN
IF CONDAVG = 1 THEN
CONDAVG = 1
ENDIF
ELSE
CONDAVG = 0
ENDIF
NEXT
TIMEWORK = 000000
TIMESTOP = 240000
F = 20
S = 200
MFIFAST = MoneyFlowIndex[F]
MFISLOW = MoneyFlowIndex[S]
BASEMFI = MFISLOW[0] > MFISLOW[F] AND MFISLOW[0] > MFISLOW[ROUND(F/2)] AND MFISLOW[0] > MFISLOW[ROUND(F/8)]
CONDMFIL = MFIFAST[0] CROSSES OVER MFISLOW[0]
//TRAILINGSTART = 50 * PIPSIZE
TRAILINGSTART = (close/((S*2)+(F*2))) * PIPSIZE
AMNT = TRAILINGSTART * POINTVALUE * COUNTOFPOSITION
//GRAPH AMNT
SIZEBUY = 1
IF CURRENTTIME >= TIMEWORK AND TIME <= TIMESTOP THEN
if not onmarket THEN
IF CONDMFIL AND BASEMFI AND CONDAVG THEN
BUY sizebuy SHARES AT highest[F](HIGH) STOP
endif
ENDIF
endif
IF ONMARKET THEN
PERFP = CLOSE - TRADEPRICE
PERFN = (PERFP / TRAILINGSTART)
TRAIL = (TRAILINGSTART/PERFN) *POINTVALUE * COUNTOFPOSITION
IF PERFP > TRAILINGSTART THEN
SET STOP $TRAILING TRAIL
ELSE
SET STOP $TRAILING AMNT
ENDIF
IF OPENTIME > 213000 AND DayOfWeek = 5 THEN
SELL AT MARKET
ENDIF
ENDIF