If you want the lower bound to be calculated by bid
#define PRICECHANNEL_LOW_PRICE bid // bid/ask/last for Low bar #include <fxsaber\PriceChannel\PriceChannel.mqh>
// Example of PriceChannel library operation on 10-second bars: TF = S10. input int inPeriod = 23; // Channel period input int NumBar = 12; // Number of the bar whose data we will output #include <fxsaber\PriceChannel\PriceChannel.mqh> // https://www.mql5.com/en/code/23418 PRICECHANNEL PriceChannel(inPeriod); // Created PriceChannel, the bar duration coincides with the chart bar. void OnInit() { PriceChannel.SetBarInterval(10); // Count 10-second bars: TF = S10. OnTick(); } #define TOSTRING(A) #A + " = " = (string)(A) + "\n" void OnTick() { static const datetime StartTime = TimeCurrent(); PriceChannel.NewTick(); // Threw a tick into the channel const MqlTick Tick = PriceChannel[NumBar]; // Get the High and Low of the corresponding S10 bar const string Str = "Duration = " + TimeToString(TimeCurrent() - StartTime, TIME_SECONDS) + "\n\n" + "Length of the timeframe = " + (string)PriceChannel.GetBarInterval() + " seconds\n" + "PriceChannel's period = " + (string)PriceChannel.GetPeriod() + " bars\n\n" + "Highest[" + (string)PriceChannel.GetPeriod() + "] = " + DoubleToString(PriceChannel.GetHigh(), _Digits) + "\n" + "Lowest[" + (string)PriceChannel.GetPeriod() + "] = " + DoubleToString(PriceChannel.GetLow(), _Digits) + "\n\n" + // It is possible to count the channel even if the period is not specified "Highest[" + (string)inPeriod + "] = " + DoubleToString(PriceChannel.GetHigh(inPeriod), _Digits) + "\n" + "Lowest[" + (string)inPeriod + "] = " + DoubleToString(PriceChannel.GetHigh(inPeriod), _Digits) + "\n\n" + // Corresponding S10 bar values "High[" + (string)NumBar + "] = " + DoubleToString(Tick.bid, _Digits) + "\n" + "Low[" + (string)NumBar + "] = " + DoubleToString(Tick.ask, _Digits); PriceChannel.SetPeriod((PriceChannel.GetPeriod() + 1) % 100); // You can change the channel period Comment(Str); }
Tested under MT4 on an Expert Advisor with adaptive periods PriceChannels.
Time of a single run without the library
755160 tick events (17243 bars, 756161 bar states) processed in 0:00:04.868 (total time 0:00:05.008)
With library
755160 tick events (17243 bars, 756161 bar states) processed in 0:00:02.293 (total time 0:00:02.434)
Otherwise everything is identical.
I.e. even in MT4 Optimisation can be twice as fast. The acceleration is a bonus, it was not done for this purpose.
No plans to add bar plotting by number of ticks and by traded volume?
Aleksey Vyazmikin:
There are no plans to add building bars by number of ticks and by traded volume?
There are no plans to add building bars by number of ticks and by traded volume?
There are no plans for this library.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
PriceChannel:
A price channel based on a bar of user-defined duration (timeframe).
Author: fxsaber