Forex Factory (https://www.forexfactory.com/forum.php)
-   Trading Systems (https://www.forexfactory.com/forumdisplay.php?f=71)
-   -   Lets Automate a Simple Renko Strategy! (https://www.forexfactory.com/showthread.php?t=531783)

shreyash Mar 19, 2015 10:10am | Post# 1

3 Attachment(s)
Hey,

I have been trading a simple Renko strategy for quiet some time now and it yields some very decent profits.
Now I want to automate this strategy into an EA so that we dont have to wait for Renko bars to paint for long hours.

The whole concept is about keeping the trading strategy simple yet Accurate & Profitable!

Ok guys so lets first see how to build a Renko chart.

How to Install renko EA:
1. Open 1Min Chart
2. Attach your Renko EA (i.e. Renko_Mod.mq4)
3. Settings for this EA are :

RenkoBoxSize=10.0
RenkoBoxOffset=0
RenkoTimeFrame=2
ShowWicks=true
EmulateOnLineChart=true
BuildChartsWhenMarketOffline=true
CalculateBestBoxSize=false
ATRPeriod=24
ATRTimeFrame=60
UseATRMA=true
MAMethod=0
MAPeriod=120
Click OK and DONE.

4. Open Offline Chart : File > Open Offline > Select EURUSD M2 (Double Click to Open this Chart)
5. Your Renko Chart is now Active.

What we are doing here is that we are getting the Renko_mod.mq4 EA to generate a renko chart in offline mode but updates on live basis.

Now on the current chart you can see renko bricks of 10 pips each.

Now add EMA 50 and EMA 21 indicators to your chart and we are done!

The Rules of the strategy are very simple!

Entry Criteria:

Buy after the brick color changes from red to green and 2 consecutive green bricks have formed and closed.
Our entry will be at the i.e. open of the third green brick.

Sell after the brick color changes from green to red and 2 consecutive red bricks have formed and closed.
Our entry will be at the i.e. open of the third red brick.

Filter:

As a filter we use 21EMA and 50EMA.
If the prices are above the EMAs we take only buy trades.
If the prices are below the EMAs we take only sell trades.

Exit Criteria:

1.When a brick of the opposite color is formed.
OR
2. Trail the trade as more number of bricks are formed until your trailing stop loss takes you out!.

Stop loss:

There are 2 concepts -
1. Last significant hi or low.
2. Hi or low of the last green or red color brick -
i.e. for a buy trade we will use the low of the last red brick from where the price turned.
for a sell trade we will use the high of the last green brick from where the price turned.

Additionally, you can use a trailing Sl of 20-30 pips to safe guard your profits.
You can choose one that best suits your style of trading.


If you are using trailing stop loss don't keep target so that we can let our profits run during times of long trends.

Now you chart should look something like this!

Sell Setup Example :

Attachment 1635545

Buy Setup Example :

Attachment 1635609

I humbly request All the talented and senior programmers on this forum to help me code a EA based on this strategy.

Fellow Members please refer this thread to anyone and anywhere where you can find talented programmers.

As I want an EA that can trade out of the offline renko chart!

All constructive suggestions will be welcomed with open arms.

Also, if you like my strategy please dont forget to thank me!!!
Renko Mod.mq4

89578251 Mar 19, 2015 11:25am | Post# 2

No red color is showed on the bars. Why?

medIce Mar 19, 2015 12:08pm | Post# 3

I might test this. I just hate that Renko is almost impossible to backtest properly. At least i havent found any good way.

babasemi Mar 19, 2015 1:46pm | Post# 4

Hi

Can you post template pls.
It makes everyone to be on the same page with you.

tnx

Jeg Mar 19, 2015 2:38pm | Post# 5

Hi shreyash
I am also interested in Renko charts, they look great when they are trending but how do you manage when it goes sideways? Thanks and regards

IAmRetep Mar 19, 2015 2:41pm | Post# 6

2 Attachment(s)
Hello,
here a diagram for a "quick and dirty" EA. If you think, we can talk about it, here is the source. Made with ForexGenerator and "Copy and paste".
Have fun and let me know, how we can improve it.
Click to Enlarge

Name: diagram.jpg
Size: 307 KB
renko_hunter.mq4

reinerh Mar 19, 2015 4:37pm | Post# 7

i am curious as to how long have you been trading this strategy ?

and how many pips have you been able to generate a month approx ?

sure sounds quite logical and promising to me.

especially since you traded this manual for a while and must have some result data.

green pips to ya

reinerh Mar 19, 2015 4:44pm | Post# 8

Hi Can you post template pls. It makes everyone to be on the same page with you. tnx
yes i second this.

Magix Mar 19, 2015 4:59pm | Post# 9

Hello, here a diagram for a "quick and dirty" EA. If you think, we can talk about it, here is the source. Made with ForexGenerator and "Copy and paste". Have fun and let me know, how we can improve it. {image} {file}
A couple of things I have noticed...but overall not terrible.

1. if ((iMA(NULL, NULL,21,0,MODE_EMA,PRICE_CLOSE,current) > iMA(NULL, NULL,50,0,MODE_EMA,PRICE_CLOSE,current)) && (Ask > iMA(NULL, NULL,21,0,MODE_EMA,PRICE_CLOSE,current)))

This is looking for the ASK to be > than the Moving Average, where as this specificity could actually miss out on the beginning of trend trades.

2. if ((Close[3] > Open[3]) && (Close[2] > Open[2]) && (Close[1] > Open[1]))

A little wordy, because in dealing with Renko, all bricks being the same size, you can simply state, (Close[1]>Close[3]);

Though I am not exactly sure this would make much of a difference...might just me being all sensitive n shit.

Personally...If it were me working the code, I would prefer to look for the beginning of the trend on confirmation, so that on longs and exit if the price closed against the Moving average...

if ((iMA(NULL, NULL,21,0,MODE_EMA,PRICE_CLOSE,current) > iMA(NULL, NULL,50,0,MODE_EMA,PRICE_CLOSE,current))&& (Bid< iMA(NULL, NULL,21,0,MODE_EMA,PRICE_CLOSE,current)) && Close[2]]<iMA&&Close[1]>iMA).....

And work the closing on:
if (Close[2]>iMA...&&Close[1]<iMA).....

This would eliminate a lot of the chop and extend the range of the trend.

It will still suck hard as an EA, but would allow you to be a lot more selective in your trades and eliminate a lot of the DD in a sideways channel.

My dos centavos

medIce Mar 19, 2015 5:09pm | Post# 10

My Mt4 Freeze after opening offline chart... Any idea what to do?

Magix Mar 19, 2015 5:22pm | Post# 11

My Mt4 Freeze after opening offline chart... Any idea what to do?
Buy a new computer...

medIce Mar 19, 2015 5:28pm | Post# 12

{quote} Buy a new computer...
It is new Lenovo with 16gb ram, 4th gen i5, geforce 840 4gb, 1tb ssd. If thats not enough them what is?

Magix Mar 19, 2015 5:31pm | Post# 13

{quote} It is new Lenovo with 16gb ram, 4th gen i5, geforce 840 4gb, 1tb ssd. If thats not enough them what is?
Proper installation of the Meta4, outside of your system32...

&&

Dropping all of the charts that you don't use.

Renko is a huge resource hound, so is meta...the combination can tax the most serious system if there is too much going on at the same time.

Right click on market watch screen.
Remove all.

This helps.

Delete historical charts of anything you are not watching
Remove the zillion indicators from any open charts and try again.

IAmRetep Mar 19, 2015 5:41pm | Post# 14

Ok, I'm out of the office until Monday, more then. On the fly, "((Close [3]> Open [3]) && (Close [2]> Open [2]) && (Close [1]> Open [1]))" is necessary because bar number 2 can have another color and so your suggestion is not true, right?
I think the recognition of a trend is simple. It starts with 3 same colored bars and ends when a bar with a different color occurs.

Is there anybody out there who can help me, setting a tester within an offline chart?

Magix Mar 19, 2015 5:58pm | Post# 15

Ok, I'm out of the office until Monday, more then. On the fly, "((Close [3]> Open [3]) && (Close [2]> Open [2]) && (Close [1]> Open [1]))" is necessary because bar number 2 can have another color and so your suggestion is not true, right?
Nope.

Really, as it is already written, makes no difference...

I did state that it's just wordy...doesn't mean it isn't as effective if not the flat out same.

All at the same time, if you check the charts previously posted...

When FASTMA>SLOWMA, price still went below for confirmation, typical trend change and then bought back...

I still thing that for longs, and for a greater run cycle, if(FASTMA>SLOWMA&&Close[2]<FASTMA[2]&&Close[1]>FASTMA[1])return (buy);, would be the way to go...

Close on if(Close[2]>FASTMA[2]&&Close[1]<FASTMA[1]);

Plus, it's your code...why the fuck would you listen to me anyways?

Do whatever you want or whatever the op wants...was just a suggestion.

IAmRetep Mar 19, 2015 6:20pm | Post# 16

[quote=Magix;8150988]{quote}

Ok guy, have you had an off day? Go and buy a book on polite conversation! Hear from you next week

MathTrader7 Mar 19, 2015 6:37pm | Post# 17

1 Attachment(s)
Here is the first version of the EA I just created. It has not been tested yet. I just started running it on a demo account on my VPS. Use this EA at your own risk.

Note: In order to enable trading on an offline chart, you have to uncheck the Offline chart option in the Common tab of the Renko chart properties (press F8 to bring up the properties window).

Edit: There is a bug in this version that may prevent the EA from opening SELL positions. I fixed the bug in Version 1.1 (see Post 45).
MathTrader7_RenkoEA.ex4

mozhixing Mar 19, 2015 6:49pm | Post# 18

I will forward test it from today, thanks.

Magix Mar 19, 2015 7:04pm | Post# 19

[quote=IAmRetep;8151020]
{quote} Ok guy, have you had an off day? Go and buy a book on polite conversation! Hear from you next week

Bit of a delicate peach, aren'tcha?

sirwolf Mar 19, 2015 8:08pm | Post# 20

Here is the first version of the EA I just created. It has not been tested yet. I just started running it on a demo account on my VPS. Use this EA at your own risk. {file}
Does this have to be applied to a Renko CHart? I have never used them before. Thanks!

MathTrader7 Mar 19, 2015 8:15pm | Post# 21

{quote} Does this have to be applied to a Renko CHart? I have never used them before. Thanks!
The EA implements the strategy described in the first post. Please read the first post to find out how to create a Renko chart.

sirwolf Mar 19, 2015 8:17pm | Post# 22

{quote} The EA implements the strategy described in the first post. Please is read the first post to find out how to create a Renko chart.
Ok, wasnt sure if the EA required the Renko chart. Thanks!

Magix Mar 19, 2015 8:45pm | Post# 23

{quote} Ok, wasnt sure if the EA required the Renko chart. Thanks!
Simple answer...no, it doesn't.

Thing about it is, if you apply it to a long enough timeframe and with a small enough risk, you will most likely still find your reward.

3 soldiers trading is not a new market concept...this is only applying moving averages to the idea.

afhacker Mar 19, 2015 10:29pm | Post# 24

1 Attachment(s)
{quote} yes i second this.
Here is the template.
Renko_mod.tpl

shreyash Mar 20, 2015 4:31am | Post# 25

Hi shreyash I am also interested in Renko charts, they look great when they are trending but how do you manage when it goes sideways? Thanks and regards
Hey Jeg!

Now thats why we use the moving averages as filter.

It keeps u away from a lot of bad trades and the chop.

Also the key here is in the money management.

Because whenever you catch a strong trend it will pay you back for a few loosing trades you have had because of the chop (unfortunately if u get caught in one) many times over because the Risk : Reward ratio is very good with this strategy.

Ex: for any given trade the Max Risk is 3 times the size of the bricks

i.e. if you are using 10pips bricks then your risk will be max 30 pips + the spread on a trade.
Or If you are trading gold and are using $1 brick then the risk will be $3 per trade in gold.

Hint : When i trade manually i just see to it that there is a visible distance between the prices or bricks and the moving averages.
Please observe that when the price tends to move near the EMAs it is generally ranging.

Playing around with the strategy for a while will teach you that.

Happy pipping!

shreyash Mar 20, 2015 4:35am | Post# 26

I might test this. I just hate that Renko is almost impossible to backtest properly. At least i havent found any good way.
You are not able to backtest renko properly because MT4 does not store tick data.
Also there are Renko based EA already on the forum and a way to back test them as well.
I will post more about it later.
But, I am sure our talented programmers on this forum will find a better way out of it.

sminage Mar 20, 2015 4:39am | Post# 27

2 Attachment(s)
Here is the first version of the EA I just created. It has not been tested yet. I just started running it on a demo account on my VPS. Use this EA at your own risk. Note: In order to enable trading on an offline chart, you have to uncheck the Offline chart option in the Common tab of the Renko chart properties (press F8 to bring up the properties window). {file}
Thanks for your effort.
I have tested it check the result attached . It takes buy only.
mathtrader7renko.rar
Click to Enlarge

Name: math7.PNG
Size: 77 KB

shreyash Mar 20, 2015 4:39am | Post# 28

{quote} A couple of things I have noticed...but overall not terrible. 1. if ((iMA(NULL, NULL,21,0,MODE_EMA,PRICE_CLOSE,current) > iMA(NULL, NULL,50,0,MODE_EMA,PRICE_CLOSE,current)) && (Ask > iMA(NULL, NULL,21,0,MODE_EMA,PRICE_CLOSE,current))) This is looking for the ASK to be > than the Moving Average, where as this specificity could actually miss out on the beginning of trend trades. 2. if ((Close[3] > Open[3]) && (Close[2] > Open[2]) && (Close[1] > Open[1])) A little wordy, because in dealing with Renko, all bricks being the same size, you can...
Welcome Magix & MathTrader7,

I am very glad that experienced programmers and traders like you have found a way on this thread!
And Having Magix & MathTrader7 on board for sure looks very promising!!!

Happy pipping!!!

shreyash Mar 20, 2015 4:43am | Post# 29

Hello, here a diagram for a "quick and dirty" EA. If you think, we can talk about it, here is the source. Made with ForexGenerator and "Copy and paste". Have fun and let me know, how we can improve it. {image} {file}
I really appreciate it!
Thank you!
I am busy with a few meetings today!
Will go test it and definitely get back to you!

shreyash Mar 20, 2015 4:50am | Post# 30

Here is the first version of the EA I just created. It has not been tested yet. I just started running it on a demo account on my VPS. Use this EA at your own risk. Note: In order to enable trading on an offline chart, you have to uncheck the Offline chart option in the Common tab of the Renko chart properties (press F8 to bring up the properties window). {file}
Now thats what i call a good start!!

Thank you MathTrader7!
I really appreciate your contribution on this thread!
I will test it and get back to you!

shreyash Mar 20, 2015 5:13am | Post# 31

{quote} Thanks for your effort. I have tested it check the result attached . It takes buy only. {file} {image}
Hey sminage!
But how can you back test this strategy on 1m chart???

I think there is another way of back testing EAs which trade thru offline charts!

Guys is this back test valid?

Please share your valuable insights!

No offences Please!
Just a constructive criticism!

MathTrader7 Mar 20, 2015 5:30am | Post# 32

{quote} Thanks for your effort. I have tested it check the result attached . It takes buy only. {file} {image}
Thanks for backtesting my EA, but it is supposed to run on a Renko chart. However, I'm surprised by it's performance on 1 minute chart! I will try to find out why it only takes Buy positions, there may be a bug in the first version....

sminage Mar 20, 2015 5:31am | Post# 33

1 Attachment(s)
{quote} Hey sminage! But how can you back test this strategy on 1m chart??? I think there is another way of back testing EAs which trade thru offline charts! Guys is this back test valid? Please share your valuable insights! No offences Please! Just a constructive criticism!
back test is done using a script named oflinetesthelper but the result may vary because in real market there is requots .
sorry for my poor language
Click to Enlarge

Name: renkohunterfomc.PNG
Size: 35 KB

Magix Mar 20, 2015 5:34am | Post# 34

{quote} Thanks for backtesting my EA, but it is supposed to run on a Renko chart. However, I'm impressed with it's performance on 1 minute chart! I will try to find out why it only takes Buy positions, there may be a bug in the first version....

I was looking at the same thing.

Lot size .1, and the few trades that show are taking 2ish pips, $2 profit.

Spread could be the killer of this idea on an M1.

MathTrader7 Mar 20, 2015 5:38am | Post# 35

{quote} Spread could be the killer of this idea on an M1.
I agree with you! In the backtest a spread of 0.3 pips is used. There is almost no broker to offer such low spread without a commission of 7.0 USD per 1 lot (0.7 pips additional spread on EURUSD).

sminage Mar 20, 2015 5:39am | Post# 36

{quote} Thanks for backtesting my EA, but it is supposed to run on a Renko chart. However, I'm surprised by it's performance on 1 minute chart! I will try to find out why it only takes Buy positions, there may be a bug in the first version....
The m1 chart is generated from the offline renko chart for back testing using a script .

MathTrader7 Mar 20, 2015 5:48am | Post# 37

{quote} Now thats what i call a good start!! Thank you MathTrader7! I really appreciate your contribution on this thread! I will test it and get back to you!
And I thank you for sharing your trading idea

shreyash Mar 20, 2015 5:57am | Post# 38

{quote} And I thank you for sharing your trading idea
Well, I thought it was payback time!
To give my 2 cents to a forum which has taught me so much in my career as a trader spanning last 8 years!

I have put your EA on demo forward testing.
Looking forward to achieve great results!

Thanks!

shreyash Mar 20, 2015 6:02am | Post# 39

1 Attachment(s)
{quote} And I thank you for sharing your trading idea
The EA has just placed a trade on the demo acc.

The EA is perfectly in sync with post 1 but as i mentioned before i usually keep my SL near the recent low.

Can we keep the stoploss to the last low ?

Pls observe the pic below.

Click to Enlarge

Name: EURUSDM2.png
Size: 28 KB

MathTrader7 Mar 20, 2015 6:07am | Post# 40

{quote} The EA has just placed a trade on the demo acc. The EA is perfectly in sync with post 1 but as i mentioned before i usually keep my SL near the recent low. Can we keep the stoploss to the last low ? Pls observe the pic below. {image}
Sure! I fix this in the next version. I also think that a Trailing Stop is a good idea to be implemented in the next version. My idea is to have three blocks size as the distance to trail the stop loss. what do you think about it?


© Forex Factory