Greetings to the ProRealCode community!
This system was made for fun and practice as I am new to programming. It is very straightforward, using multiple time-frames and indicators to filter trades which are launched from the 5m timeframe.
This system is purely experimental and probably curve fitted to a large extent. However, I did try to optimize some of the variables and I performed a number walk-forward tests. It was fun playing with different indicators and using the WF tool!
DEFPARAM CUMULATEORDERS = false
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 080000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 183000
timeEnterAfter = time < noEntryAfterTime
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 5 OR OpenDayOfWeek = 2
//Establish a trend on a higher timeframe - 4hr
timeframe(4 hour,updateonclose)
MA24 = average[5]
Rplse1 = Repulse[5](close)
c2 = close > MA24
c3 = Rplse > 0
c5 = close < MA24
c6 = Rplse < 0
c7 = Rplse1 > 0
c8 = Rplse1 < 0
//Filter a trend on a medium timeframe - 1hr
timeframe (1 hour, updateonclose)
Rplse = Repulse[5](close)
MA20 = average[20]
cA = MA20 < close
cB = MA20 > close
cC = RocnRoll(close) < 2 and RocnRoll(close) > -1
cD = RocnRoll(close) > 1
exitL1 = RSI[14](close)> 80
exitS1 = RSI[14](close)< 20
//These conditions nested together establish direction of the trend. The system will only trade in the direction of trend
bullT = (c2 AND c3 AND cA AND c7 and cC)
bearT = (c5 AND c6 AND cB AND c8 and cD)
//This is the timeframe from which entry signals will be activated
timeframe(5 minute, default)
//buy entry conditions
buyC = Repulse[5](close) crosses over 0
IF bullT AND buyC AND (timeEnterBefore AND timeEnterAfter AND NOT daysForbiddenEntry) THEN
buy at market
set stop trailing AverageTrueRange[14](close)*3.5
ENDIF
// Conditions to exit long positions
ExitL = RocnRoll(close) > 1 and RocnRoll(close) < 1
IF ExitL or exitl1 THEN
SELL AT MARKET
ENDIF
//sell entry conditions
sellC = Repulse[5](close) crosses under 0
IF bearT AND sellC AND (timeEnterBefore AND timeEnterAfter AND NOT daysForbiddenEntry) THEN
sellshort at market
set stop trailing AverageTrueRange[14](close)*3.5
endif
//conditions to exit short positions
ExitS = RocnRoll(close) < 2
IF ExitS or exits1 THEN
exitshort at market
ENDIF
Thanks everyone
J
Line 55 condition will never be true?
ExitL = RocnRoll(close) > 1 and RocnRoll(close) < 1
I have tested it when ‘true’ and it seems to make a huge difference to the gain. Seemed a bit unrealistic though.
Apologies if much of the code is not correct. I genuinely have no idea apart from the most basic programming. This is merely for fun and learning.
tested over 100k candles, don’t have access to 200k unfortunately 🙁
is that a 1 million back-test???
is that a 1 million back-test???
Yes it is; v11 PRT Premium allows it
that’s amazing…. I thought the maximum was 200k! Do you think that optimizing on over 1 million candles is too much?
I asked myself the same question, here’s the topic: https://www.prorealcode.com/topic/1m-backtest-available-how-do-you-manage-it/
Anyway in a general understanding i think it’s pretty much useless rn; but could be very helpful in low timeframe systems (<1m)
have tested it when ‘true’ and it seems to make a huge difference to the gain.
True means a condition is met and using ‘GRAPH condition’ would result in a ‘1’ on a Chart.
Below can never be True / 1 because how can RocnRol be both > 1 and < 1 at the same time?
The condition below is doing nothing in your strategy.
When you say above “have tested it when ‘true’ and it seems to make a huge difference to the gain.” then you must have made a change that made ExitL = True / 1, for example used OR instead of AND, or changed values for RocnRol etc?
GRAPH ExitL below as it is written in your strategy (using AND) and you will see a straight line at 0?
Sorry to labour the point, but I’m hoping it helps you and others understand about True and False and use of GRAPH?
ExitL = RocnRoll(close) > 1 and RocnRoll(close) < 1
Yes GraHal, but it works no matter what owing to line 37, so they are likely not to care much.
Ah but they will care when a similar faux pas doesn’t execute trades and they hopefully will think … what was GraHal on about re True and False!? 🙂
thanks Grahal!
You are right, it should have been ‘OR’ instead of ‘AND’