ProRealCode - Trading & Coding with ProRealTime™
Ahhh.. I got it. Thanks
I heard an episode of the podcast “better system trader” with a “mean reversion expert”, i cant remember name or episode tho, its one of the older ones. he talks alot about how he uses the RSI in 4 hour and 1 hour (mtf) to create good strategies. Im working on RSI in mtf now and seeing some interesting results, nothing amazing so far tho, pic includes the latest im working on, first algo ive seen working in EU stox so im kinda happy with that, but yea no amazing results so far but im gonna optimize it now and see what happens..
Its long and short, i like to optimize the long and short seperatly to increase the speed of the optimization. As long as i already know that it will not affect the other long/short strategy i figured that should be safe and fine to do, and it saves me a ton of time either optimizing long or short 1 at a time or optimizing them together which could take hours..
Hi all,
Here I upload my version…
I like this concept, I called it: MULTI-SIMPLICITY TYPE A
// MULTI-SIMPLICITY TYPE A
DEFPARAM CumulateOrders = false // Cumulating positions
DEFPARAM PreLoadBars = 1000 //cargar informacion
//Parameters to be optimized
//Pentry1=6
//Kprofit=1.5
ontime=1
IF hour <= 2 or hour >= 22 then
ontime=0
ELSIF DayOfWeek <= 1 and hour <= 4 then
ontime=0
ELSIF DayOfWeek >= 5 and hour >= 20 then
ontime=0
ENDIF
MetaRange=max(pipsize,pipsize*round(average[34](average[21](average[13](average[8](average[5](round(range/pipsize))))))))
/////////// LEO CHANNEL //////////////////
PXentry1=max (2, round(0.6*Pentry1) )
highest1=highest[Pentry1](high)
IF highest1 = highest1[PXentry1] then
Re1=highest1
ENDIF
IF high > Re1 then
Re1=high
ENDIF
lowest1=lowest[Pentry1](low)
IF lowest1 = lowest1[PXentry1] then
S1=lowest1
ENDIF
If low < S1 then
S1=low
ENDIF
ConditionLong00001= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
ConditionShort00001= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
timeframe(15 minutes,updateonclose)
ConditionLong00002= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
ConditionShort00002= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
timeframe(30 minutes,updateonclose)
ConditionLong00003= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
ConditionShort00003= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
timeframe(60 minutes,updateonclose)
ConditionLong00004= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
ConditionShort00004= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
timeframe(120 minutes,updateonclose)
ConditionLong00005= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
ConditionShort00005= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
timeframe(240 minutes,updateonclose)
ConditionLong00006= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
ConditionShort00006= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
timeframe(default)
ConditionLong = ConditionLong00001 + ConditionLong00002 + ConditionLong00003 + ConditionLong00004 + ConditionLong00005 + ConditionLong00006
ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006
//----------------------------------------------------------
// >>>>>>>>>>>>>> ENTRY POSITIONS <<<<<<<<<<<<<<<<<<
//----------------------------------------------------------
// ---> LONG POSITIONS
IF NOT LongOnMarket and ontime=1 THEN
IF ConditionLong > 2 THEN
stoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pips
targetprofitlong=stoplosslong*Kprofit //in pips
BUY 1 CONTRACTS AT MARKET
SET STOP pLOSS stoplosslong
SET TARGET pPROFIT targetprofitlong
ENDIF
ENDIF
// ---> SHORT POSITIONS
IF NOT ShortOnMarket and ontime=1 THEN
IF ConditionShort > 2 THEN
StopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pips
targetprofitshort=StopLossShort*Kprofit // in pips
SELLSHORT 1 CONTRACTS AT MARKET
SET STOP pLOSS StopLossShort
SET TARGET pPROFIT targetprofitshort
ENDIF
ENDIF
//---------------------------------------------------------
//>>>>>>>>>>>>>>>>>> EXIT POSITIONS <<<<<<<<<<<<<<<<<<
//---------------------------------------------------------
If LongOnMarket THEN
//////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE ////////////////
//If close > TRADEPRICE+targetprofitlong*pipsize THEN
//SELL AT MARKET
//ENDIF
//IF close < TRADEPRICE-stoplosslong*pipsize THEN
//SELL AT MARKET
//ENDIF
IF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THEN
Kexit=((TRADEPRICE+targetprofitlong*pipsize)-highest[BARINDEX-TRADEINDEX+1](high)) / ( (TRADEPRICE+targetprofitlong*pipsize) - (TRADEPRICE+0.75*stoplosslong*pipsize))
IF low < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize and close < typicalprice then
SELL AT MARKET
ELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THEN
SELL AT MARKET
ENDIF
ENDIF
////////////////////////////
IF CLOSE < S1[1] THEN
SELL AT MARKET
ENDIF
IF high > TRADEPRICE + 0.75*stoplosslong*pipsize THEN
SET STOP pLOSS 0.01
ENDIF
IF TIME > 214500 and DayOfWeek=5 then
SELL AT MARKET
ENDIF
ENDIF
// Bedingungen zum Ausstieg aus Short-Positionen
IF ShortOnMarket THEN
//////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE ////////////////
//IF close < TRADEPRICE-targetprofitshort*pipsize THEN
//EXITSHORT AT MARKET
//ENDIF
//IF close > TRADEPRICE+stoplossshort*pipsize THEN
//EXITSHORT AT MARKET
//ENDIF
IF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize and (BARINDEX-TRADEINDEX)>=2THEN
Kexit=(lowest[BARINDEX-TRADEINDEX+1](low)-(TRADEPRICE-TargetProfitShort*pipsize) ) / ( (TRADEPRICE-0.75*stoplossshort*pipsize)-(TRADEPRICE-TargetProfitShort*pipsize))
IF high > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize and close > typicalprice THEN
EXITSHORT AT MARKET
ELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
////////////////////////////////
IF CLOSE > Re1[1] THEN
EXITSHORT AT MARKET
ENDIF
IF low < TRADEPRICE - 0.75*stoplossshort*pipsize THEN
SET STOP pLOSS 0.01
ENDIF
IF TIME > 214500 and DayOfWeek=5 then
EXITSHORT AT MARKET
ENDIF
ENDIF
Jebus89… It looks very nice.
Can you share the conditions… I have several ideas about RSI as well like
ConditionLong00001=RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<30
I like this concept, I called it: MULTI-SIMPLICITY TYPE A
Here the walk forward
its nothing atm just trying out something like:
(this is short, reverse for long)
timeframe daily: rsi 2 > 95
timeframe 4 hours: rsi 2 > 95
timeframe 1 hour: rsi crosses under 95
Sell at daily timeframe when rsi 2 crosses under 30
I think its very easy to curvefit something like this so im very sceptical but honestly it also looks applicable in different markets.
then again if its easy to curvefit, maybe some reoptimizing every x month might work wonders… gonna walk it forward and see what happens, obviously no stop, no traget, no trailing, no filter has been added..
I just made something with RSI, looks very nice as well
// MULTI-SIMPLICITY TYPE A
DEFPARAM CumulateOrders = false // Cumulating positions
DEFPARAM PreLoadBars = 1000 //cargar informacion
//Parameters to be optimized
//Pentry1=6
//Kprofit=1.5
//Krsi=30
ontime=1
IF hour <= 2 or hour >= 22 then
ontime=0
ELSIF DayOfWeek <= 1 and hour <= 4 then
ontime=0
ELSIF DayOfWeek >= 5 and hour >= 20 then
ontime=0
ENDIF
MetaRange=max(pipsize,pipsize*round(average[34](average[21](average[13](average[8](average[5](round(range/pipsize))))))))
/////////// LEO CHANNEL //////////////////
PXentry1=max (2, round(0.6*Pentry1) )
highest1=highest[Pentry1](high)
IF highest1 = highest1[PXentry1] then
Re1=highest1
ENDIF
IF high > Re1 then
Re1=high
ENDIF
lowest1=lowest[Pentry1](low)
IF lowest1 = lowest1[PXentry1] then
S1=lowest1
ENDIF
If low < S1 then
S1=low
ENDIF
ConditionLong00001= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
ConditionShort00001= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
timeframe(15 minutes,updateonclose)
ConditionLong00002= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
ConditionShort00002= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
timeframe(30 minutes,updateonclose)
ConditionLong00003= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
ConditionShort00003= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
timeframe(60 minutes,updateonclose)
ConditionLong00004= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
ConditionShort00004= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
timeframe(120 minutes,updateonclose)
ConditionLong00005= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
ConditionShort00005= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
timeframe(240 minutes,updateonclose)
ConditionLong00006= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
ConditionShort00006= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
timeframe(default)
ConditionLong = ConditionLong00001 + ConditionLong00002 + ConditionLong00003 + ConditionLong00004 + ConditionLong00005 + ConditionLong00006
ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006
//----------------------------------------------------------
// >>>>>>>>>>>>>> ENTRY POSITIONS <<<<<<<<<<<<<<<<<<
//----------------------------------------------------------
// ---> LONG POSITIONS
IF NOT LongOnMarket and ontime=1 THEN
IF ConditionLong > 2 THEN
stoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pips
targetprofitlong=stoplosslong*Kprofit //in pips
BUY 1 CONTRACTS AT MARKET
SET STOP pLOSS stoplosslong
SET TARGET pPROFIT targetprofitlong
ENDIF
ENDIF
// ---> SHORT POSITIONS
IF NOT ShortOnMarket and ontime=1 THEN
IF ConditionShort > 2 THEN
StopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pips
targetprofitshort=StopLossShort*Kprofit // in pips
SELLSHORT 1 CONTRACTS AT MARKET
SET STOP pLOSS StopLossShort
SET TARGET pPROFIT targetprofitshort
ENDIF
ENDIF
//---------------------------------------------------------
//>>>>>>>>>>>>>>>>>> EXIT POSITIONS <<<<<<<<<<<<<<<<<<
//---------------------------------------------------------
If LongOnMarket THEN
//////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE ////////////////
//If close > TRADEPRICE+targetprofitlong*pipsize THEN
//SELL AT MARKET
//ENDIF
//IF close < TRADEPRICE-stoplosslong*pipsize THEN
//SELL AT MARKET
//ENDIF
IF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THEN
Kexit=((TRADEPRICE+targetprofitlong*pipsize)-highest[BARINDEX-TRADEINDEX+1](high)) / ( (TRADEPRICE+targetprofitlong*pipsize) - (TRADEPRICE+0.75*stoplosslong*pipsize))
IF low < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize and close < typicalprice then
SELL AT MARKET
ELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THEN
SELL AT MARKET
ENDIF
ENDIF
////////////////////////////
IF CLOSE < S1[1] THEN
SELL AT MARKET
ENDIF
IF high > TRADEPRICE + 0.75*stoplosslong*pipsize THEN
SET STOP pLOSS 0.01
ENDIF
IF TIME > 214500 and DayOfWeek=5 then
SELL AT MARKET
ENDIF
ENDIF
// Bedingungen zum Ausstieg aus Short-Positionen
IF ShortOnMarket THEN
//////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE ////////////////
//IF close < TRADEPRICE-targetprofitshort*pipsize THEN
//EXITSHORT AT MARKET
//ENDIF
//IF close > TRADEPRICE+stoplossshort*pipsize THEN
//EXITSHORT AT MARKET
//ENDIF
IF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize and (BARINDEX-TRADEINDEX)>=2THEN
Kexit=(lowest[BARINDEX-TRADEINDEX+1](low)-(TRADEPRICE-TargetProfitShort*pipsize) ) / ( (TRADEPRICE-0.75*stoplossshort*pipsize)-(TRADEPRICE-TargetProfitShort*pipsize))
IF high > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize and close > typicalprice THEN
EXITSHORT AT MARKET
ELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
////////////////////////////////
IF CLOSE > Re1[1] THEN
EXITSHORT AT MARKET
ENDIF
IF low < TRADEPRICE - 0.75*stoplossshort*pipsize THEN
SET STOP pLOSS 0.01
ENDIF
IF TIME > 214500 and DayOfWeek=5 then
EXITSHORT AT MARKET
ENDIF
ENDIF
I’ve had an RSI MTF strategy based on four time frames running on forward test on demo since the 22 August. Not many trades but profitable.
[attachment file=89886]
[attachment file=89887]
…and this is the in sample that is still available for back test.
[attachment file=89888]
[attachment file=89891]
The long only strategy has a simple daily market sentiment indicator that stops entry in major down markets. It enters if the fast RSI on all four time frames is below a certain level and exits if all four time frame RSI ‘s are over a certain level. It will also check once every 24 hours and if the trade is in profit it will also exit.
There is some light money management in there but it is very light. I worry about the market sentiment filter being over optimized but otherwise it so far seems pretty robust. Very few trades to give confidence yet though.
I think mtf is going from 2d to 3d. theres infinite shit to do.. im going kinda crazy just thinking about it.
Still havnt found a rly good way to take advantage just yet tbh, but i think it could help alot with the setup of the trade. Like saying “where the price has been before your entry” in multiple timeframes to better sort out at what “level” the price is on (high, low, mid range compared to X)
Looks sexy @Vonasi, could u share the “check if profitable every 24h and exit if profitable`” code?
The trouble with MTF is that as we bore down to faster time frames we lose data to test on. I go to bed at night dreaming of PRT offering me 35 years of data on all time frames. Sure back testing would be horrendously slow but I’d put up with that for the other benefits!
could u share the “check if profitable every 24h and exit if profitable`” code?
No rocket science involved.
timeframe (default)
if not onmarket and (my conditions) then
buy positionsize contracts at market
tme = time
endif
if onmarket and close > positionprice and time = tme then
sell at market
endif
haha 35 years ye 😛
Thanks for the code, any chance ur willing to share what ur “disaster filter” is here?
“has a simple daily market sentiment indicator that stops entry in major down markets”
Are we talking like a moving average or an actual indicator? Any chance ud share? my long only systems might want this lol
any chance ur willing to share what ur “disaster filter” is here?
It is nothing special – just a look back to check that price is higher than it was a while back. Hence my concern that it is over fitted. As far as I am aware it has not been triggered yet in the forward test and wasn’t in the back test. It is just there to shut the strategy down in a big downturn. probably too late but better than nothing.
I am still searching for the ‘holy grail’ market sentiment filter that fits multiple markets and have not found it yet despite sometimes thinking that I am close. This last year indices have done all they can to disprove all previous ideas and so proving that history does not repeat itself – well at least not when we want it to!
MultiTimeFrame simple conditions
This topic contains 32 replies,
has 5 voices, and was last updated by jebus89
7 years ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 01/28/2019 |
| Status: | Active |
| Attachments: | 11 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.