Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Thank you. I have already tried DonChian channels and unfortunately they are not suitable for my needs. If I were to use a ready-made indicator, a better option would be Bollinger Bands Squeeze.
However, this won't help me understand where the error is in my idea of finding the range.
thank you again!
Help. I'm stuck. I'm trying to find the range in a chart using the bool function. Unfortunately, I always get True. What am I doing wrong? Please help. This is my beginning with mql5.
maybe so?
#property script_show_inputs input int Bars = 200; //+------------------------------------------------------------------+ void OnStart() { double price = 1.10359; bool isRange = IsRange(price, Bars); string result = isRange?"inside":"outside"; Print("Price "+string(price) + " is "+result + " the range of the first "+string(Bars) +" bars"); } //+------------------------------------------------------------------+ bool IsRange (double value, int bars, int start_bar=0) { double max = iHigh(_Symbol,PERIOD_CURRENT,iHighest(_Symbol,PERIOD_CURRENT,MODE_HIGH,bars,start_bar)); double min = iLow(_Symbol,PERIOD_CURRENT, iLowest(_Symbol,PERIOD_CURRENT,MODE_LOW, bars,start_bar)); return value<=max && value>=min; }
2023.12.31 01:55:39.969 FindRange (EURUSD,M1) Price 1.1 is outside the range of the first 200 bars 2023.12.31 01:56:24.212 FindRange (EURUSD,M1) Price 1.10359 is inside the range of the first 200 bars
Thank you Nikolai. I tried your solution and unfortunately, when I check whether the current price is within or outside the range, the result is true.
I would like to find the range, for example 20 bar, but iHigh/iLow updates the values and each new result is within the range. I do not understand this.
Thank you Nikolai. I tried your solution and unfortunately, when I check whether the current price is within or outside the range, the result is true.
I would like to find the range, for example 20 bar, but iHigh/iLow updates the values and each new result is within the range. I do not understand this.
I can't understand the task. You need to clearly formulate the task. Write this problem in two languages: your native and English, please.
Chcę znaleźć na wykresie zakres przykładowo 20 świec w którym cena porusza się pomiędzy minimum i maksimum. Moim pomysłem było znalezienie minimum i maksimum za pomocą iHigh and iLow z ostatich 20 świec i ich aktualizacja jeżeli warunki nie będą spełnione, to znaczy jeżeli cena wybije minimum i maksimum wcześniej niż przed 20 świecą. Niestety funkcja którą napisałem zawsze ma wartość true.
Cel jaki chcę osiągnąć poprzez tą funkcję to znalezienie obszarów kiedy rynek porusza się w zasięgu i wyłączenie tych obszarów z handlu.
I want to find a range, for example, 20 bars on the chart in which the price moves between the minimum and maximum. My idea was to find the minimum and maximum using iHigh and iLow from the last 20 bars and update them if the conditions are not met, i.e. if the price hits the minimum and maximum earlier than before the 20th candle. Unfortunately, the function I wrote always has the value true.
The goal I want to achieve with this function is to find areas when the market is moving within range and exclude these areas from trading.
my Mql and my English are not the best so thank you for your patience.
Chcę znaleźć na wykresie zakres przykładowo 20 świec w którym cena porusza się pomiędzy minimum i maksimum. Moim pomysłem było znalezienie minimum i maksimum za pomocą iHigh and iLow z ostatich 20 świec i ich aktualizacja jeżeli warunki nie będą spełnione, to znaczy jeżeli cena wybije minimum i maksimum wcześniej niż przed 20 świecą. Niestety funkcja którą napisałem zawsze ma wartość true.
Cel jaki chcę osiągnąć poprzez tą funkcję to znalezienie obszarów kiedy rynek porusza się w zasięgu i wyłączenie tych obszarów z handlu.
I want to find a range, for example, 20 bars on the chart in which the price moves between the minimum and maximum. My idea was to find the minimum and maximum using iHigh and iLow from the last 20 bars and update them if the conditions are not met, i.e. if the price hits the minimum and maximum earlier than before the 20th candle. Unfortunately, the function I wrote always has the value true.
The goal I want to achieve with this function is to find areas when the market is moving within range and exclude these areas from trading.
my Mql and my English are not the best so thank you for your patience.
Perhaps you want to catch a breakout from a horizontal price channel. If so, then the last (zero) bar should be checked against the range of previous ones (for example, 20 bars) starting from the 1st bar to the 20th.
Do you want that?
IIf so, then it is better to use not the range, but these two functions to check whether the last bar is an extremum for the last N bars:
bool IsNewMaxForLastN_Bars (int N_Bars) { return iHighest(NULL,0,MODE_HIGH,N_Bars)==0; } bool IsNewMinForLastN_Bars (int N_Bars) { return iLowest(NULL,0,MODE_LOW,N_Bars)==0; }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Help. I'm stuck. I'm trying to find the range in a chart using the bool function. Unfortunately, I always get True. What am I doing wrong? Please help. This is my beginning with mql5.