/////////////////////////////////////////////////////// // // SaherElm IT Center XMTR Indicator // --------------------------------------------- // retrieve market base info ... // // 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 XMKT Indicator" #property strict // // START Inputs ... // // // Market Specifications ... input int marketLength = 20; // Market Length input int atrMultiplier = 1; // ATR Multiplier input int atrLength = 5; // ATR Period input ENUM_APPLIED_PRICE source = PRICE_CLOSE; // Source // // END Inputs ... // // // START Global Definitions: Variables, Properties and etc ... // #property indicator_chart_window // // define indicator buffers ... #property indicator_buffers 3 #property indicator_plots 3 // // Declare Buffers ... #define trendBufferIndex 0 #define upTrendBufferIndex 1 #define downTrendBufferIndex 2 // double trendBuffer[]; double upTrendBuffer[]; double downTrendBuffer[]; // // Includes our shared library ... #include "../Libraries/x-saherelm.lib.mq4" // // END Global Definitions: Variables, Properties and etc ... // // // Start Event Handlers ... // // // Initialization ... int OnInit() { // // Initialize what we want ... // // Validating Input Parameters ... if (marketLength <= 0) { return INIT_PARAMETERS_INCORRECT; } // // here we specify logging enabled or not ... enableLogging = true; // // this is a Tag which attached to our Logger ... logTag = "XMTR"; // // TREND ... SetIndexLabel(trendBufferIndex, "Trend"); SetIndexBuffer(trendBufferIndex, trendBuffer); SetIndexStyle( trendBufferIndex, DRAW_LINE, STYLE_DOT, 1, clrNONE ); // // UP Trend ... SetIndexLabel(upTrendBufferIndex, "Up Trend"); SetIndexBuffer(upTrendBufferIndex, upTrendBuffer); SetIndexStyle( upTrendBufferIndex, DRAW_LINE, STYLE_DOT, 1, clrNONE ); // // DOWN Trend ... SetIndexLabel(downTrendBufferIndex, "Down Trend"); SetIndexBuffer(downTrendBufferIndex, downTrendBuffer); SetIndexStyle( downTrendBufferIndex, DRAW_LINE, STYLE_DOT, 1, clrNONE ); // // initialization done ... return(INIT_SUCCEEDED); } // // DeInitialization ... void OnDeinit(const int reason) { // RemoveDraws(logTag); } // // Do Calculation ... int OnCalculate( const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] ) { // // this counts Available Bars ... int limit; // // because in some cases we may have more than one input for // calculation and we must prevent any calculation // untill we pass the biggest input length, here we get max Input length // and then wait until pass it ... int maxLength = MathMax(marketLength, 3); // // input variable, we return 0 means nothing passed ... if (rates_total < maxLength) { return 0; } // // found which candles calculated before ... limit = (prev_calculated == 0) ? rates_total - maxLength - 1 : rates_total - prev_calculated + 1; // // this is the main loop of calculations, for each bar index ... for (int i = limit - 1; i >= 0; i--) { // // Start Calculation here ... // i is bar_index ... // // Calculate Short Cycle ... CalculateBuffers( i, low ); } // return rates_total; } // // END Event Handlers ... // // // START Functions ... // // // Calculate Short Cycle ... void CalculateBuffers( const int bar_index, const double &low[] ) { // double atr = GetMarketTRSMA( bar_index, atrLength ); // double smoothedAtr = (atr * atrMultiplier); double upTrend = low[bar_index] - smoothedAtr; double downTrend = low[bar_index] + smoothedAtr; // double cciValue = GetMarketCCI( bar_index, marketLength, source ); // // TODO: Complete this ... } // // END Functions ... //