# Thread: Market high and low

1. ## Market high and low

any way to keep ea from trading if at top of market price during the past (x) weeks and low as well.

ex.

eurusd range 1.4177 - 1.3748

thanks

2. You find the highest high like this:

Code:
`double HighestHigh = iHigh( string symbol, int timeframe, iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0) )`
The opposite applies in finding the lowest low. You just need to define the variables.

3. thanks for the quick responce!

im not quite a coder yet

would i put this in front of the int start or int openbuyorder

thanks

4. Firstly, you need to tidy the code up and insert the correct variables. Let's say that you want the highest high for the last two weeks, you would need to change it to something like this:

Code:
`double HighestHigh = iHigh( Symbol(), 1440, iHighest( Symbol, 1440, MODE_HIGH, 12, 0) );`
The 1440 refers to the number of minutes in the D1 timeframe. The 12 refers to the last 12 days. I have used 12 instead of 10 because some brokers have a price bar for the 2 or 3 hours that they are open on a Sunday evening. For these brokers, the market is effectively open 6 days a week, while it is only open for 5 days with other brokers.

You would put that block of code towards the top of your start() function.

I don't know exactly what you want to use as your rule, but let's suppose that you don't want to trade if the price is within 50 pips of its 2 week high. You would need some further code underneath the first line like this:

Code:
`if(MathAbs(HighestHigh-Bid)<=50*Point) return(0);`
The MathAbs function effectively turns negative numbers into positive numbers. So if you are within 50 pips either below or above the high, the return(0) instruction will just send control back to the beginning of the start() function and the rest of the code will remain unread until the price moves one way or the other away from its recent high.

5. this is exactly what im looking for! Thank you - Thank you - Thank you...

im using vforce 2 and trying to avoid open orders for more than a few days.

thanks again

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•