It is an automated strategy used for Brent oil CFD on 5 minute chart with good results since October 2015 as i don’t have more data to run it. Trailing stop code from Nicolas.
If anyone is able to run the backtest for a longer time then please post it here. As you will see, there is no 0 bars on the backtest. Any idea for improving the code is welcome.
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
//defparam flatbefore = 230000
//defparam flatafter = 065500
// Conditions to enter long positions
indicator1 = TimeSeriesAverage[12](close)
indicator2 = WilderAverage[60](close)
c1 = (indicator1 >= indicator2)
indicator3 = SMI[14,2,16](close)
c2 = (indicator3 CROSSES OVER -44)
IF c1 AND c2 THEN
BUY 2 CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
indicator4 = TimeSeriesAverage[28](close)
indicator5 = WilderAverage[88](close)
c3 = (indicator4 <= indicator5)
indicator6 = SMI[8,1,16](close)
c4 = (indicator6 >= 45)
IF c3 AND c4 THEN
SELLSHORT 2 CONTRACT AT MARKET
ENDIF
//////////////////////////////////////////////////////////////////////////
////Trailing stop logikk
//////////////////////////////////////////////////////////////////////////
//trailing stop
trailingstop = 34
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif
SET STOP ploss 62//20
SET TARGET pPROFIT 98//54
You must be logged in to post a comment.
volpiemanuel.
I back tested your strategy again now and could not find the same results as before. I will try and reproduce the results with some tweaking.
I did not run the strategy because the backtest on Oil does not seem stable to me. On IG the backest frames only goes back to about a month.
@vorster
hi,
wich parameter do you use for your test with starting capital of 100$ ?And SL/TP which value ? Tanks
Hi Kennith.
Only read your code now.
I tested on PRT 10.3
Tested your code with various capital and time frames. Even with intial capital of just $100 it performs well. Best results got from time frame 2min over 100,000 (x)units. Then the next good results are between 18-24min again. Strange in these time frames (18-24min) the graph only shows trade from 14March 2017 onwards. Before that is flatline.
For me personally it says a lot if code/autotrade performs well with initial small amount of capital.
Great code!! and nicely commented as well.!
Hope this helps.
Hi..
I have been working for many months now and have not tested it or done anything since last I posted a tread here.
Anyone that have been running it on 10.3 backtest mode? I am now on vication and very eeger to start again soon
GAMMA. I dont know how ninja trader setup is.. it would e nice to test and see:)
To Reb: the new version will come february to IG.com , new version has inside candel information. So it will be more accurate an reliable when we backtest. That means that we can tweek the code better.
Hi everyone.
I tried to upload a screenshot of my live acc. That i started around 20july and ended around 20september.
Looks like i need to sit on computer since I cant upload from my phone.
I will try to do this later.
Anyway I run the automated startegy live and gained 1000euro before it had a drawdown with 1000 euro, as many know I stopped the strategy since it had some few diffrenses with backtest and live but looks like we are close to figure something out.
Is there anybody who would like to run the strategy with a tick by tick version 10.3 prt.
I am a ig user and cant do.much before ig gets version 10.3 around february 2017
I have stoped the system due to diffrenses between backtest and live acc. I AM curently waiting til februry when ig relises new. Version for prt
@ rev
You 'd best write that problem to IG.
They should sort out why there was a dfference and wether the problem is IG or PRT.
It must become clear to you as a customer what happened exactly. You are paying fees to IG for the brokerage.
If the answers of IG are not satisfying PRT should be informed about that. PRT supplies their software to IG, so IG is a customer of PRT. If IG gives wrong prices or their integrity is in doubt, PRT should be aware of that.
Hello Kenneth! Thank you for sharing this strategy. I have one question; how did you calculate the amount of pips to set as your profit target and stop loss?
Best Regards,
Johan
There are some.diffrenses yes. PRT can be a pain.in the xxx..
Its nothing to do about it. I BELIVE this is for all automaded strategies in.backtest and live acc. It will.never be 100% accurate is my belife. Mybe in the new prt version it will.be more realistic??
Hi Kenneth, hi all
I find a new difference between PRT and IG
On the 23rd, sept, the strat opened a short at 11:50 (Paris, Berlin time) and was stopped by IG at 15:32 (because trailing stop moved the stop at 4818 at 15h10)
The backtest doesn't recalculate the stop. So, it was never reached and the TP was reached a few hours later.
In one week, there are 2 differences between IG and PRT. The consequence is a difference of - 160 pips
Did you notice that before ?
Regards,
Reb
Hi everyone.
I have been on vication so I have not seen or done anyhing with all the posts or the strategy.
I am currently still running it with not too much profits yet.
Why the backtest did a position while the live acc. Did I have no clue about it.
The best guy to answer for this is mybe Nicolas or someone else that have doen PRT longer than me.
Thanks Reb; do you suggest any other strategy on Brent?
thanks