This is my first autosystem, thanks to the many people in this web that help me with it. I designed it with the idea of being versatile so it can work within bulls, bears and neutrals periods, also with different markets, timeframes or indicators. I put here one of the setups I designed but I have tried others with similar results in backtesting, e.g. DOW-15m-MACD.
There´s not size management. I have tried roughly several approachs but I was not convinced about them. I decided to leave the size of the positions to the monetary circumstances of each one. Also it can be a good topic to contribute ideas here.
I can only backtest with 100k candles, it would be nice if someone can do it before that.
To use you need to import in PRT the Divergence Indicator “Divergence-RSI-V3.itf” and the system itself “The Grinder-EUSD-5M-v0.itf”
SETUP:
HOW IT WORKS:
// System parameters
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 2000
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 190000
LimitEntryTime = 184000 //No Entries after this time
// Divergence Indicator RSI
ignored, DRSI = CALL "Divergence RSI v3"[24,8,1,0]
BullishDivergence = DRSI = 1
BearishDivergence = DRSI = -1
// Filter to avoid entries on a trend (Delayed Donchian Canal with a Margin)
NotBearTrend = LOWEST[120](close[15]) < (close+((close*SafetyMargin)/100))
NotBullTrend = HIGHEST[120](close[15]) > (close-((close*SafetyMargin)/100))
SafetyMargin = 0.15
// Conditions for Entry of Long Positions
IF BullishDivergence AND NotBearTrend AND OPENTIME<=LimitEntryTime THEN
BUY 1 CONTRACTS AT MARKET
ELSIF SHORTONMARKET AND ((CLOSE-TRADEPRICE)/TRADEPRICE)*100 > FlipPosition THEN// Change from short to long position when the FlipPosition Stop reached, because a trend is underway
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions for Entry of Short Positions
IF BearishDivergence AND NotBullTrend AND OPENTIME<=LimitEntryTime THEN
SELLSHORT 1 CONTRACTS AT MARKET
ELSIF LONGONMARKET AND ((CLOSE-TRADEPRICE)/TRADEPRICE)*100 < -FlipPosition THEN// Change from long to short position when the FlipPosition Stop reached, because a trend is underway
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Loss, Profit and Flip Stops
SET STOP %LOSS 3 // Not used because the Flip Stop is lower, just in case.
SET TARGET %PROFIT 3
FlipPosition = 1.5 // It this %Loss is reached the position turns in the opposite direction (Long->Short or Short->Long)
// END
You must be logged in to post a comment.
Ok, but you are missing the 120 lookback period
Hi rama, It means the lowest close of the last 120 candels starting 15 candles back from the present candle. Be ware this strategy is not profitable, has been loosing money all the last year. Anyway I think it still has useful ideas, maybe for longer timeframes Best of luck
Hi C,
The hours the System don´t opperate the market use to be more flat so the highs and lows are not very far from each other and the System needs some distance betwenn H/L to react well. I backtested the System with different open/close times and this seen to be the best
Done!
https://www.prorealcode.com/topic/the-grinder-eurusd-5-min-intraday-trading-strategy/
Thanks for your patience GraHal, this is a new world for me. And for appreciate my work :)
Yes, somehow it seems logical for you to raise a Forum Thread and with the same title as this Thread? Then feedback you seek can benefit from images being able to be added (images can't be added to this Library posts) to explain things better.
I think your System is good and has potential to be even better.
GraHal
No problem for me... should myself do it? I have no attachment to add
Sorry my wrong, missed the "flip position" line :)
Aloysius,
Would you so kind to post your results here?:
https://www.prorealcode.com/topic/the-grinder-eurusd-5-min-intraday-trading-strategy/
Thanks
Thanks Aloysius, too bad the results are not good. I will appreciate very much if you can post them in the forum, to see how it behave. Anyway I still like the idea of the system, I will try to improve it.
Hi DEIO,
Answering your questions:
1. when the position is flipped in the opposite direction, where the closure of the loosing trade is ??
It would follow the same rules that any other trade. It can:
2. The majority of trades at what % are closed ? (apart time expiry and 3% plus)
With my max bars allowed backtesting (100.000) the statistics are: Average Win: 192$ and Average Loss: -225$. But the results by trade are very varied because the system can change direction several times in the same day and it goes from 0 to -1.882/+3.173
I hope this help you understand the system better
Hi Joachim,
Thanks for sharing, but I am not sure about that. The base of the system with wich I created it is taking the highs and lows continuosly during the day (high-low-high-low...), that´s way the stop loss and profit are so high for this timeframe and rarely used So I think it´s normal it doesn´t work separately. I would nice to know the results of backtest before the one I can get (100.000) to know if it´s too optimized as you think.
Thanks anyway :)
Hey TempusFugit!
Thanks for your code but im sorry to say that it dosn´t work in it´s current state.
You have over optimized it to work with the order of the trades, like - short-long-long-short-long and so on. If you split the code in one short side and on long side you will not get a very pleasing resault...
If I could I would add a picture but it´s not possible here.
Hi DEIO,
Thank you for collaborate
I am not sure what are you trying... to replicate the "Equity Cuve" shown by PRTBackTest? And I am not sure to follow your code, e.g. what is "one"?, but is it possible that the piece I copy below make your code only take in account the trades with 3% profit or those that reach 19:00? Because these trades are minority
if perf >= 3 or time > timestop then
//graph perfc
capital = capital + PERFC
graph capital
Also, you canceled the 3%TakeProfit so the system is changed.
Maybe I can´t understand your code because I am also a newbie, can any expert enlight us?
Also if you are worried about the PRT calculation of P/L, I think you can verify it checking each trade calculation of P/L and total them. Is that what worries you?
Hi TempusFugit,
it's true that didn't consider all the trades of the strategy.... I'm checking....
Anyway usaually I try to replicate the E.L. of PRT (as best I can), because this way I'm more confident about what I'm coding.
Probably I haven't completely understood your criteria's strategy, anyway in order to try a Money management
in my mind it's necessary to calculate the current capital and so the plusminus of any trade.
About 3% target ... I tried to manage manually as I said before (just where you said that there are the minority of trades).
And results are the same you got with your original code.
Two questions:
1. when the position is flipped in the opposite direction, where the closure of the loosing trade is ??
2. The majority of trades at what % are closed ? (apart time expiry and 3% plus)
Anyway I can't judge PRT calculations !!! but I'd like to understand how the strategy works exactly :)
I hope I was clear ..
Thx.
I forgot to say that I am looking forward for feedback about this strategy. Is my first autosystem and sincerely I have no idea if I am going in the right direction and I hope you people with more experience help me. Thanks
hi TempusFugit,
I tried to make some manual calculation of the performance in order to insert in the strategy some Money Management, but I stopped
myself when I saw results.
It's possible that I'm wrong but let's try you too, using the attached code below.
It's seems that when the performance are quite stick to zero level (between plus or minus) prorelatime the most of time
say that you win (even if a little amount), but by a manually calculation you loose.
You can see the equity line manually calculated.
So, I hope to be wrong (I'm am a new member...), but if I am right I would be worried about PRT results.
Please let me know your opinion or whoever can help us.
thx
code:
// System parameters
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 2000
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 190000
LimitEntryTime = 184000 //No Entries after this time
//-----------------------------------------------------------------------------------
//timestop 5 inutes before FLATAFTER in order to let me calculate manually perf
timestop = 185500
if one = 0 then
capital = 10000
one = 1
endif
//-----------------------------------------------------------------------------------
// Divergence Indicator RSI
ignored, DRSI = CALL "Divergence RSI v3"[24,8,1,0]
BullishDivergence = DRSI = 1
BearishDivergence = DRSI = -1
// Filter to avoid entries on a trend (Delayed Donchian Canal with a Margin)
NotBearTrend = LOWEST[120](close[15]) < (close+((close*SafetyMargin)/100))
NotBullTrend = HIGHEST[120](close[15]) > (close-((close*SafetyMargin)/100))
SafetyMargin = 0.15
// Conditions for Entry of Long Positions
IF BullishDivergence AND NotBearTrend AND OPENTIME<=LimitEntryTime THEN
BUY 1 CONTRACTS AT MARKET
ELSIF SHORTONMARKET AND ((CLOSE-TRADEPRICE)/TRADEPRICE)*100 > FlipPosition THEN// Change from short to long position when the FlipPosition Stop reached, because a trend is underway
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions for Entry of Short Positions
IF BearishDivergence AND NotBullTrend AND OPENTIME<=LimitEntryTime THEN
SELLSHORT 1 CONTRACTS AT MARKET
ELSIF LONGONMARKET AND ((CLOSE-TRADEPRICE)/TRADEPRICE)*100 < -FlipPosition THEN// Change from long to short position when the FlipPosition Stop reached, because a trend is underway
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
//-----------------------------------------------------------------------------------
//manually calculation of performance
if onmarket then
if LONGONMARKET then
perf = (close - POSITIONPRICE)/POSITIONPRICE * 100
perfc = (close - POSITIONPRICE) * POINTVALUE * COUNTOFPOSITION *10000
endif
if shortonmarket then
perf = (-close + POSITIONPRICE)/POSITIONPRICE * 100
perfc = (-close + POSITIONPRICE) * POINTVALUE * COUNTOFPOSITION *-1 *10000
endif
if perf >= 3 or time > timestop then
//graph perfc
capital = capital + PERFC
graph capital
if longonmarket then
sell at market
endif
if shortonmarket then
exitshort at market
endif
endif
endif
//-----------------------------------------------------------------------------------
// Loss, Profit and Flip Stops
SET STOP %LOSS 3 // Not used because the Flip Stop is lower, just in case.
//SET TARGET %PROFIT 3
FlipPosition = 1.5 // It this %Loss is reached the position turns in the opposite direction (Long->Short or Short->Long)
Hello, I tried to run the code but i had an syntax error that "This variable is not used in the code:limitentrytime". Can you help me?