DEFPARAM cumulateorders = false
TIMEWORK = 070000
TIMESTOP = 210000
acc = 5
if justone = 0 then
capital = 10000 * pointvalue
justone = 1
endif
perccap = 0.5
margin = 0.5 * close * pointvalue / 100
period=5
stdev=STD[period](close)
//LOOK FOR A LOCAL VOLATILITY DECREASE
//I WANT TO BUY AGAIN ONLY WHEN BEAR MARKET SHOWS A LOCAL PAUSE
if (stdev[0]+stdev[1]+stdev[2]+stdev[3]+stdev[4]) < (stdev[1]+stdev[2]+stdev[3]+stdev[4]+stdev[5]) then
SWBUY=1
else
SWBUY=0
ENDIF
IF TIME > TIMEWORK AND TIME < TIMESTOP THEN
if not onmarket then
sizebuy = ROUND((capital *perccap /100)/ margin)
tp = 0.25
IF CLOSE < CLOSE[1] THEN
BUY sizebuy SHARES AT MARKET
endif
endif
if Onmarket then
if longonmarket then
perf = (close - POSITIONPRICE)/POSITIONPRICE * 100
else
perf = (POSITIONPRICE - close)/POSITIONPRICE * 100
endif
if perf > tp then
SELlshort AT MARKET
perfc = (close - POSITIONPRICE) * POINTVALUE * COUNTOFPOSITION
capital = capital + PERFC
ELSE
IF LASTBARBUY = 0 THEN
if (((CLOSE-TRADEPRICE)/TRADEPRICE)*100) > acc AND SWBUY=1 then
sizebuy = ROUND((capital *perccap /100)/ margin)
BUY sizebuy SHARES AT MARKET
LASTBARBUY = 1
ENDIF
ELSE
LASTBARBUY = 0
ENDIF
ENDIF
ENDIF
ENDIF