What would be the best way to determine a range in an EA

 

What would be the best way to determine a range in an EA.

I am thinking of starting an EA that would start a trade on the breakout of a ranging market. Except I can't think of the best way to determine a ranging market and the highs and lows.

I would think it would be something like trading X many of bars inside iHighest[x] and iLowest[x]. However they has to be a better formula to determine how many bars to look back to where the range begins instead of just a fixed X many bars back.

I just can't seem to wrap my mind around what to look for.


If some more info is needed I would be glad to provide it. Hope my question makes since.


Thanks

-Maxss280


 

Simplest is to pick your pair and timeframe, then add indicators Envelopes and Bollinger Bands

When the Bolli bands are within the Envelopes, the price will be ranging

So when price and/or a Bolli band breaks the envelope that can be a breakout

As ever watch time of day as well

-BB-

 

Thanks BarrowBoy but I am not sure I understand what you mean. Is it when the middle line of the BB is in the Envelopes?


Thanks.


 

I used this before. Base bars are the maximum bars to look for. Then I only consider a base if barindex_high < 485 for example, because if it's 500 it may be just a downtrend and there is no base.

   int base_bars = 500; //Base bars are the maximum bars to look for. 
   double base_high = Close[iHighest(NULL, 0, MODE_CLOSE, base_bars, 2)];
   double base_low = Close[iLowest(NULL, 0, MODE_CLOSE, base_bars, 2)];
   double barindex_high = iHighest(NULL, 0, MODE_CLOSE, base_bars, 2);
   double barindex_low = iLowest(NULL, 0, MODE_CLOSE, base_bars, 2);

 
maxss280:

Thanks BarrowBoy but I am not sure I understand what you mean. Is it when the middle line of the BB is in the Envelopes?


Thanks.


if you use the bb-envelopes methode, you have to adjust the deviation of the envelopes to a confortable level... also upper and lower bb-band have to be inside of the envelopesband

//z

Reason: