//+------------------------------------------------------------------+ //| iVIDyA Get Value.mq5 | //| Copyright © 2020, Vladimir Karputov | //+------------------------------------------------------------------+ #property copyright "Copyright © 2020, Vladimir Karputov" #property version "1.00" //--- input parameters input group "VIDyA" input int Inp_VIDyA_cmo_period = 409; // VIDyA: period for Chande Momentum input int Inp_VIDyA_ema_period = 337; // VIDyA: EMA smoothing period input int Inp_VIDyA_ma_shift = 0; // VIDyA: horizontal shift on the price chart input ENUM_APPLIED_PRICE Inp_VIDyA_applied_price = PRICE_OPEN; // VIDyA: type of price input int Inp_VIDyA2_cmo_period = 95; // VIDyA2: period for Chande Momentum input int Inp_VIDyA2_ema_period = 599; // VIDyA2: EMA smoothing period input int Inp_VIDyA2_ma_shift = 0; // VIDyA2: horizontal shift on the price chart input ENUM_APPLIED_PRICE Inp_VIDyA2_applied_price = PRICE_OPEN; // VIDyA2: type of price //--- int handle_iCustom, handle_iCustom2; // variable for storing the handle of the iCustom indicator int handle_iVIDyA, handle_iVIDyA2; // variable for storing the handle of the iVIDyA indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create handle of the indicator iCustom handle_iCustom=iCustom(Symbol(),Period(),"Examples\\VIDYA",Inp_VIDyA_cmo_period, Inp_VIDyA_ema_period,Inp_VIDyA_ma_shift,Inp_VIDyA_applied_price); handle_iCustom2=iCustom(Symbol(),Period(),"Examples\\VIDYA",Inp_VIDyA2_cmo_period, Inp_VIDyA2_ema_period,Inp_VIDyA2_ma_shift,Inp_VIDyA2_applied_price); //--- if the handle is not created if(handle_iCustom==INVALID_HANDLE || handle_iCustom2==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- create handle of the indicator handle_iVIDyA=iVIDyA(Symbol(),Period(),Inp_VIDyA_cmo_period, Inp_VIDyA_ema_period,Inp_VIDyA_ma_shift,Inp_VIDyA_applied_price); handle_iVIDyA2=iVIDyA(Symbol(),Period(),Inp_VIDyA2_cmo_period, Inp_VIDyA2_ema_period,Inp_VIDyA2_ma_shift,Inp_VIDyA2_applied_price); //--- if the handle is not created if(handle_iVIDyA==INVALID_HANDLE || handle_iVIDyA2==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iVIDyA 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) { //--- if(handle_iCustom!=INVALID_HANDLE) IndicatorRelease(handle_iCustom); if(handle_iCustom2!=INVALID_HANDLE) IndicatorRelease(handle_iCustom2); if(handle_iVIDyA!=INVALID_HANDLE) IndicatorRelease(handle_iVIDyA); if(handle_iVIDyA2!=INVALID_HANDLE) IndicatorRelease(handle_iVIDyA2); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- double custom[],custom2[],vidya[],vidya2[]; ArraySetAsSeries(custom,true); ArraySetAsSeries(custom2,true); ArraySetAsSeries(vidya,true); ArraySetAsSeries(vidya2,true); int start_pos=0,count=3; if(!iGetArray(handle_iCustom,0,start_pos,count,custom)) return; if(!iGetArray(handle_iCustom2,0,start_pos,count,custom2)) return; if(!iGetArray(handle_iVIDyA,0,start_pos,count,vidya)) return; if(!iGetArray(handle_iVIDyA2,0,start_pos,count,vidya2)) return; //--- string text="",text2=""; int limit=(count>3)?3:count; for(int i=0; i