PriceChannel - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

PriceChannel The highest and lowest price during the selected period.
This cross-platform library allows calculating PriceChannel without attributing it to standard bars, i.e. by price movement.
Therefore, PriceChannel can be calculated over any time range, including one-second time ranges. It can also serve as a tick-by-tick channel.
// PriceChannel library operation example Input integer period = 1 ; // channel period input boolean PriceChannel = true ; // Enable/disable calculation of PriceChannel via library #Define PRICECHANNEL_LOW_PRICE bid // the bid/ask/last price of the lowest price bar #include// https://www.mql5.com/en/code/23418 //Highest price of the last iPeriod bar Double get high ( constant integer i period) { static double high[]; highcopy ( _symbol , PERIOD_CURRENT , 0 , iPeriod, highpoint); return (high[ arraymax (high)]); } // lowest price of the last iPeriod bar Double reduction (during constant integer i) { static double low[]; lowCopy ( _symbol , PERIOD_CURRENT , 0 , iPeriod, low); return (low[ array minimize (low)]); } sum of doubles = 0 ; blank check () { static constant integer bar interval = period seconds ( PERIOD_CURRENT ); static PRICECHANNEL PriceChannel(inPeriod); // Create a PriceChannel object with a predefined period static integer bar count = 0 ; static datetime previous time = 0 ; if (in price channel) PriceChannel.NewTick(); // Consider new tick if ( time current () / BarInterval != PrevTime / BarInterval) // new column count bar++; If (Number of bars > MAX_BARS) // Calculation starts when the relevant history records are accumulated. Sum += inPriceChannel ? PriceChannel.GetHigh() - PriceChannel.GetLow() // Calculate PriceChannel via library : GetHigh(inPeriod) - GetLow(inPeriod); // Calculate PriceChannel via standard method. Previous time = time current (); } double tester () { return (and); }
The EA will show the same results in the tester: standard results and results obtained through the library.
Standard calculation
Optimization completed, the total number of passes was 200. The optimization was completed in 6 minutes and 55 seconds. The shortest path was 0 : 00 : 01.061 , the longest pass was 0 : 00 : 03.432 , and the average pass rate was 0 : 00 : 02.066.
via library
Optimization completed, the total number of passes was 200. The optimization was completed in 2 minutes and 57 seconds. The shortest path was 0 : 00 : 00.764 , the longest pass was 0 : 00 : 01.982 , and the average pass rate was 0 : 00 : 00.862.
Attachment download
📎 pricest_base.mqh (1.2 KB)
📎 pricest.mqh (5.67 KB)
📎 pricest_copy.mqh (5.67 KB)
📎 highest.mqh (0.33 KB)
📎 lowest.mqh (0.34 KB)
📎 pricechannel.mqh (2.51 KB)
📎 pricechannel_example.mq5 (1.52 KB)
Source: MQL5 #23418
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •