Good Day
I have been a silent member of this community for quite some time but suppose as time would allow I would try to become more active. I have been developing PRT strategies for almost 2 years now and have quite a few running live and profitable on various indexes and FX Pairs. I still need to get to a point where I can freely share my strategies but still find that slightly difficult (especially knowing some people sell your IP for profit). Anyhow this is just one of the many rabbit hole strategies I have developed in an effort to outperform a given index.
I actually wrote this today when the idea came to me to write a small time frame strategy that attempts to enter the market and take profit as soon as possible with the ability to stop and reverse direction quickly if the position becomes unprofitable. I am sure the general idea can be adapted to other timeframes and markets.
///Spread set to 0.9 points
possize = 1
pointsp = 20 //points where profit is to be locked in
pointsb = 36 //points where stop is to be taken
fast = average[11,4](close)
medium = average[13,4](close)
If countofposition = 0 then
If fast > medium then
BUY possize CONTRACT AT open + averagetruerange[3](close)*2 stop
EndIf
EndIf
If longonmarket and close >= positionprice + pointsp then
If close < close[1] then
SELL AT MARKET
EndIf
ElsIf longonmarket and close <= positionprice - pointsb then
SELLSHORT possize*2 CONTRACT AT MARKET
EndIf
If shortonmarket and close <= positionprice - pointsp then
If close > close[1] then
EXITSHORT AT MARKET
EndIf
ElsIf shortonmarket and close >= positionprice + pointsb then
BUY possize*2 CONTRACT AT MARKET
EndIf
SET TARGET pPROFIT 50
You must be logged in to post a comment.
Hi juanj , thanks for posting this. I'm with IG and have been trying to run it on US 500 but orders keep getting rejected. Any idea why that might be?
Hi, Please forgive my question... I'm an absolute beginner. I'm trying to trade the US 500 1€ on a 25 contract base. So, changed "1" on line 3 into 25. I presume other numbers must be changed. Would you be good enough telling which ones, please.
I cant attach the picture here, shall we exchange email?
thats weird, I get a completely different result..
I tried to post it here but something doesnt seem to work..
///Spread set to 0.9 points for SP500
///Spread set to 3 points for DAX
//DEFPARAM flatafter = 230000
//defparam flatbefore= 080000
possize = 1
pointspl = 110//20 for SP500 //points where profit is to be locked in
pointsbl = 85//36 for SP500 //points where stop is to be taken
pointsps = 90 //20 for SP500 //points where profit is to be locked in
pointsbs = 105 //36
a = 2.1
b=2
pf = 100
periodfast = 3
periodmedium = 15
fast = average[periodfast,4](close) //11,4 for SP500
medium = average[periodmedium,4](close) //13,4 for SP500
If countofposition = 0 then
If fast > medium then
BUY possize CONTRACT AT open + averagetruerange[3](close)*a stop
EndIf
EndIf
If countofposition = 0 then
If fast < medium then
sellshort possize CONTRACT AT open - averagetruerange[3](close)*b stop
EndIf
EndIf
If longonmarket and close >= positionprice + pointspl then
If close < close[1] then
SELL AT MARKET
EndIf
ElsIf longonmarket and close <= positionprice - pointsbl then
SELLSHORT possize*2 CONTRACT AT MARKET
EndIf
If shortonmarket and close <= positionprice - pointsps then
If close > close[1] then
EXITSHORT AT MARKET
EndIf
ElsIf shortonmarket and close >= positionprice + pointsbs then
BUY possize*2 CONTRACT AT MARKET
EndIf
SET TARGET pPROFIT pf //50 for SP500
Hi I created an optimized version that differentiate between long and short and that allows the first trade to be short
Hi @Benjamin, unfortunately as I have mentioned before I cannot say that I use this strategy. It was purely conceptual in design. I did post a version of the above adapted for the DAX. See earlier comments. However I cannot advise using this strategy without at least running it live for a month or so. Even then re-optimization would be necessary to ensure performance related to then 'current' market conditions.
Hi Juanj, thanks for sharing this, are you using the same sp500-optimizer-5min-strategy.itf for the German 30?
Cheers
Thanks for your comments, juanj, probably explains why I tend to optimize a strategy and then find I lose money when I trade it. The trouble is one can optimise today and market conditions change tomorrow I get the point about a tight range of variables though
Thanks again
Dymjohn
@Dymjohn The above strategy is largely conceptual and hence not optimized using walk forward testing. I do however use walk forward tests extensively on development of my core strategies to establish a good set of optimized variables to start off with. However that said walk forward tests will never guarantee future performance, although a tight range of variables will show that you are on the right track. There is no such thing as a magic set of variables. It is necessary to regularly optimize variables to ensure your strategy is suited to current market conditions.
Hi Zilliq, thank you for taking the time in doing some walk forward testing. You mentioned you used 6 valuables, but there is only 5 that requires optimization. Also what variable ranges did you use? As a side note, it is worth noting that frequent variable optimisation can keep a time optimised strategy surprisingly profitable. Just keep an eye on the equity curve.
Hello Juanj, I really like this concept. I especially like the possibility of a reversal when the market is going against you. I have created several versions with different inputs (RSI2, close>close(1) etc.) and with the possibility to go short or long as the first trade if the trend demands it. I also changed the diagnosis of the trend. It performs very well in so many markets. Of course, it's often on the market for a very long time. Is that a good thing or a bad thing? Do you use this concept? Do you maybe have a few tips for me?