hi,
I reviewed the last strategy using contrarian orders and I added more filters in order not to accumulate too much contracts.
The base logic is “buy”.
Furthermore the system try to follow automatically the uptrend when it appears.
Inside the code I trid to explain the main parameters to use.
Actually such code is the automatisation of a my old “manual” strategy that I use since 2010 (using a simply Excel that give me the operating signals) using ETF instruments (It seems to me that even on IG it is possible to use ETF – isn’t it?).
The strategy that I am posting today works on long periods of time, so the broker (i.e. IG) withdraw an amount of cash every night (CFD cash) .
For what I know this is a blocking problem because overnight interest destroy any good strategy.
If I am wrong on what I’m saying please let me know if you can help me to resolve this problem (that’s why I sopke about ETF instrument which are not hit by this issue).
Moreover using CFD future with own expiry date I suppose that the issue on overnight interest doesn’t exist. Isn’t it?
But this way, how can I think to use an automatic strategy if I have to rollover every expiry date ?
What do you think on this ? keep in mind that I’m not an expert on future …. 🙂
Anyway I would be happy if you can “play” with the parameters of my strategy in order to know your opinion (let’s try on the main index or monetary market).
Thx a lot.
code:
//-----------------------------------------------------------------------------------------------
//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 = true
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