/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Indicator // --------------------------------------------- // Name: XCT // Description: Trend Magic Indicator ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "SaherElm XCT Indicator" #property strict // // START Constants ... // // #define ShortName "XCT" #include "../Libraries/x-saherelm.common.lib.mq5" // // END Constants ... // // // START Inputs ... // // input color clr = clrYellow; // Text Color input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER; // Text Position // input group "Presentation"; input bool showCandleTime = true; // Show Candle Time // // END Inputs ... // // // START Buffers ... // // #property indicator_chart_window // #property indicator_buffers 0 #property indicator_plots 0 // // END Buffers ... // // // START Global Definitions: Variables, Properties and etc ... // // // END Global Definitions: Variables, Properties and etc ... // // // START Event Handlers ... // // // Initialization ... int OnInit() { // // Validate Inputs ... if (showCandleTime) { CreateIndicatorObject(); } else { ObjectDelete(0, ShortName); } // // Set Indicator ShortName ... SetIndicatorName(); // // Init Succeed ... return INIT_SUCCEEDED; } // // DeInitialization ... void OnDeinit(const int reason) { // // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function // REASON_REMOVE 1 Program removed from a chart // REASON_RECOMPILE 2 Program recompiled // REASON_CHARTCHANGE 3 A symbol or a chart period is changed // REASON_CHARTCLOSE 4 Chart closed // REASON_PARAMETERS 5 Inputs changed by a user // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings // REASON_TEMPLATE 7 Another chart template applied // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value // REASON_CLOSE 9 Terminal closed // ulong chID = FindChartID( _Symbol, _Period // ); // // Delete Object ... ObjectDelete(chID, ShortName); // Comment(""); } // // Calculating what we want ... int OnCalculate( const int rates_total, // Total Bars on Chart ... const int prev_calculated, // Total Calculated Bars on Charts ... const datetime &time[], // History of Open Time ... const double &open[], // History of Open Price ... const double &high[], // History of High Price ... const double &low[], // History of Low Price ... const double &close[], // History of Close Price ... const long &tick_volume[], // History of Tick Volumes on Bar ... const long &volume[], // History of Trade Volumes ... const int &spread[] // History of Spread Price ... ) { // ArraySetAsSeries(time, true); // if (!showCandleTime) { return rates_total; } // ulong chID = FindChartID( _Symbol, _Period // ); // XBarRemainsTime barRemains; barRemains.Init( _Symbol, _Period // ); // string msg = barRemains .ToString( "", "", "", "", "", ":", true // ); // long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD); // string _sp = ""; if (mSpread < 10) _sp = ".."; else if (mSpread < 100) _sp = "."; // string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in: " + msg; // ObjectSetInteger(chID, ShortName, OBJPROP_COLOR, clr); ObjectSetString(chID, ShortName, OBJPROP_TEXT, objText); ObjectSetInteger(chID, ShortName, OBJPROP_FONTSIZE, 10); ObjectSetString(chID, ShortName, OBJPROP_FONT, "Courier"); // return rates_total; } // // END Event Handlers ... // // // START Functions ... // // // Set Indicator Short Name and also we can define Buffers Labels ... void SetIndicatorName() { IndicatorSetString(INDICATOR_SHORTNAME, ShortName); } // void CreateIndicatorObject() { // if (!showCandleTime) { return; } // ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0); ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner); ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10); ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2); // ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER; switch (corner) { case CORNER_LEFT_UPPER: Anchor = ANCHOR_LEFT_UPPER; break; case CORNER_RIGHT_UPPER: Anchor = ANCHOR_RIGHT_UPPER; break; case CORNER_LEFT_LOWER: Anchor = ANCHOR_LEFT_LOWER; break; case CORNER_RIGHT_LOWER: Anchor = ANCHOR_RIGHT_LOWER; break; } // ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor); } // // END Functions ... //