//+------------------------------------------------------------------+ //| BarsCalculated.mq5 | //| Copyright © 2019, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2019, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.000" #property description "Output BarsCalculated" //--- input parameters //--- ADX input int Inp_ADX_adx_period=140; // ADX: averaging period //--- int handle_iADX; // variable for storing the handle of the iADX indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create handle of the indicator iADX handle_iADX=iADX(Symbol(),Period(),Inp_ADX_adx_period); //--- if the handle is not created if(handle_iADX==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iADX indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { int bars=Bars(Symbol(),Period()); int ibars=iBars(Symbol(),Period()); int bars_calculated=BarsCalculated(handle_iADX); PrintFormat("Bars: %d iBars: %d BarsCalculated: %d", bars,ibars,bars_calculated); //--- } //+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ void OnTradeTransaction(const MqlTradeTransaction &trans, const MqlTradeRequest &request, const MqlTradeResult &result) { //--- } //+------------------------------------------------------------------+