Librerías: PriceChannel

 

PriceChannel:

Canal de precios de una duración aleatoria (timeframe) de la barra.

Autor: fxsaber

 
Si desea que el límite inferior se calcule por puja
#define  PRICECHANNEL_LOW_PRICE bid  // bid/ask/last para la barra Low
#include <fxsaber\PriceChannel\PriceChannel.mqh>
 
// Ejemplo de funcionamiento de la librería PriceChannel en barras de 10 segundos: TF = S10.
 
input int inPeriod = 23; // Período del canal
input int NumBar = 12;   // Número de la barra cuyos datos vamos a imprimir

#include <fxsaber\PriceChannel\PriceChannel.mqh> // https://www.mql5.com/es/code/23418

PRICECHANNEL PriceChannel(inPeriod); // Creado PriceChannel, la duración de la barra coincide con la barra del gráfico.

void OnInit()
{
  PriceChannel.SetBarInterval(10); // Contar barras de 10 segundos: TF = S10.
  
  OnTick();  
}

#define  TOSTRING(A) #A + " = " = (string)(A) + "\n"

void OnTick()
{
  static const datetime StartTime = TimeCurrent();
  
  PriceChannel.NewTick(); // Lanza un tick al canal
  
  const MqlTick Tick = PriceChannel[NumBar]; // Obtiene el Máximo y el Mínimo de la barra S10 correspondiente

  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" +
                     
                     // Es posible contar el canal aunque no se especifique el periodo
                     "Highest[" + (string)inPeriod + "] = " + DoubleToString(PriceChannel.GetHigh(inPeriod), _Digits) + "\n" +
                     "Lowest[" + (string)inPeriod + "] = " + DoubleToString(PriceChannel.GetHigh(inPeriod), _Digits) + "\n\n" +

                     // Valores de barra S10 correspondientes
                     "High[" + (string)NumBar + "] = " + DoubleToString(Tick.bid, _Digits) + "\n" +
                     "Low[" + (string)NumBar + "] = " + DoubleToString(Tick.ask, _Digits);
                     
  PriceChannel.SetPeriod((PriceChannel.GetPeriod() + 1) % 100); // Puedes cambiar el periodo del canal
                      
  Comment(Str);
}
 

Probado bajo MT4 en un Asesor Experto con periodos adaptativos PriceChannels.


Tiempo de una sola ejecución sin la biblioteca

755160 tick events (17243 bars, 756161 bar states) processed in 0:00:04.868 (total time 0:00:05.008)


Con la biblioteca

755160 tick events (17243 bars, 756161 bar states) processed in 0:00:02.293 (total time 0:00:02.434)


Por lo demás, todo es idéntico.


Es decir, incluso en MT4 optimización puede ser dos veces más rápido. La aceleración es un bono, no se hizo para este propósito.

 
¿No hay planes para añadir el trazado de barras por número de ticks y por volumen negociado?
 
Aleksey Vyazmikin:
¿No hay planes para añadir la construcción de barras por número de ticks y por volumen negociado?

No hay planes para esta biblioteca.