Can anyone code this simple EA? - page 6

To add comments, please log in or register
ralphronnquist
420
ralphronnquist  
matrixebiz:
No, I don't see it. Did you forget to attach it?

I don't know what I did but now it should be attached (again).

matrixebiz
1733
matrixebiz  
ralph.ronnquist:
I don't know what I did but now it should be attached (again).

Got it now, thanks

matrixebiz
1733
matrixebiz  
ElectricSavant:
Average true range is an indicator in the MT4 library with a default setting of 14P (I often use 24P Daily or 576P H1)

For example why would the stops and TP's on a more volatile pair that had double the range be the same?...

Load all 19 IBFX pair on the platform with the ATR indicator and compare the readings.

Then figure out what the stops and tp's should be based on their differences...you could use a multiplier based off of the illustrated target pair as a base...if the other pair that you are thinking of using is 1.5 times more in it ATR value you could multiply the thread authors suggested stop loss and TP by 1.5.

There are other methods to determine a comparable sl or tp...this a is just one of them...some may not agree that ATR is the best one...

ES

Sorry, not getting it Can you post a chart, marking out the values you would look at?

Thanks

Michael B
3377
Michael B  

No I cannot. The value of the indicator is in the upper left corner of the indicator pane...just try adding it and see it.

This would be Forex101 to try and explain that different pairs have different volatilities, ranges and directional trends. Simply it is easier to get 20 pips in the GBP/JPY than it is to get 20 pips in the EUR/CHF..or EUR/GBP...

Some feel the ATR is not an accurate way to do this and that ADR is the better way...

ES

matrixebiz:
Sorry, not getting it Can you post a chart, marking out the values you would look at? Thanks
thehedge
4
thehedge  
ralph.ronnquist:
The attached EA might do what you expect (?).

Drop it on GBPUSD,H1

Parameters:

* SAMPLE_HOUR is the hour at which to sample the price (bid price)

* EXPIRES is the number of hours past SAMPLE_HOUR to expire

* OP is the pips offset off sample price required to trigger trade

* TP is the takeprofit pips offset off open price

* SL is the stoploss pips offset off open price

* lots is the trade size

Hi Ralph,

Thanks for writing this very useful ea.

Would it be possible to take it one step further by incorporating a variable into the calculation of the entry, take profit and stop loss levels? What I am trying to do is to calculate the mean of the ranges of the last five 24-hour periods (a trading week) from 7am GMT and use this variable (since it changes everyday at 7am GMT) in determining entry, tp and sl.

For example, if it is 7am GMT now, I would like to find the range in pips (high to low) of the last 24 hours (not necessarily a daily bar on the chart), and that of 24 hours to 48 hours ago, and that of 48 hours to 72 hours ago, etc. for five 24-hour periods. I will then like to calculate the mean of these 5 ranges, e.g. (60+70+60+80+70)/5 = 68, and use this number to determine entry, tp and sl as follows:

At 7am GMT, with a mean 24-hour range of 68pips, entry will be set at 50% of 68pips (34 pips above price at 7am GMT and 34 pips below price at 7am GMT). The trade will be entered in whichever direction price breaks out first. Tp will then be set at 75% from price at 7am GMT (both ways) and sl at 25% from price at 7am GMT (both ways).

I will then like to close all trades and calculations 1 hour before 7am GMT the next day (i.e. 6am GMT the next day, similar to Arsenic's ea) and at 7am GMT the next day, calculate the mean of the ranges of the last five 24-hour periods again. This takes place on a daily basis and the variable at 7am GMT everyday will change. How do I write an ea for this and ensure the variable stays in the system for 23 hours before being recalculated at the start of the next 24 hour period?

Hope I have not confused anyone with my explanation. Would really be very grateful if Ralph or anyone else could modify Arsenic's ea for this purpose.

Thanks all.

ralphronnquist
420
ralphronnquist  

The attached EA is an Arsenic variant that computes the OP, TP and SL settings rather than using input parameters, and it includes a CLOSE_HOUR parameter to tell at which hour all trades should be closed.

The OP, TP and SL are computed by using the simple moving average of price range of the five 24-hour periods preceding the most recent SAMPLE_HOUR, with OP = 50% of the range, TP = 75% of the range, and SL = 25% of the range.

Just was what you asked for, thehedge, yes? It tests nicely

Files:
thehedge.mq4 6 kb
thehedge
4
thehedge  
ralph.ronnquist:
The attached EA is an Arsenic variant that computes the OP, TP and SL settings rather than using input parameters, and it includes a CLOSE_HOUR parameter to tell at which hour all trades should be closed.

The OP, TP and SL are computed by using the simple moving average of price range of the five 24-hour periods preceding the most recent SAMPLE_HOUR, with OP = 50% of the range, TP = 75% of the range, and SL = 25% of the range.

Just was what you asked for, thehedge, yes? It tests nicely

Thanks ralph! Very nice indeed.

To add comments, please log in or register