//-----------------------------------------------------------------------------------------------
//TF a 12 h
//dax min 1 Eur.
//-----------------------------------------------------------------------------------------------
//TAKE PROFIT NEAR ZERO IN ORDER TO NOT ACCUMULATE TOO MUCH
//-----------------------------------------------------------------------------------------------
//IF NOT ON MARKET TRY TO ENTER AGAIN AS SOON A CORRECTION APPEARS, TRYING TO FOLLOW
//THE POTENTIAL CURRENT UPTREND
//-----------------------------------------------------------------------------------------------
//IF I BOUGHT THE PREVIOUS BAR DON'T BUY THE FOLLOWING BAR IN ORDER TO NOT ACCUMULATE TOO MUCH
//-----------------------------------------------------------------------------------------------
//MAIN PARAMETER IN ORDER TO CHANGE THE RISK LEVEL ARE:
//acc----> % of decrease of the instrument compared to the last buy price (THE LOWER IS AND MORE
// RISK AND CASH RETURN WILL APEEAR)
//-----------------------------------------------------------------------------------------------
//tp-----> % beyond which the entire position is closed (THE HIGHER IS AND MORE
// RISK AND CASH RETURN WILL APEEAR) - below zero is safer !
//-----------------------------------------------------------------------------------------------
//MONEY MANAGENT "ANTIMARTINGALA" STYLE - I SUPPOSE CLEARER RESULTS ON A LONGER PERIOD OF BACKTEST
//-----------------------------------------------------------------------------------------------
DEFPARAM cumulateorders = false
DEFPARAM Preloadbars = 20000
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 LONGONMARKET then
perf = (close - POSITIONPRICE)/POSITIONPRICE * 100
if perf > tp then
SELl 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