Conversion of indicator SuperSlopeZeroLine from MT4

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #185169 quote
    Igven
    Participant
    New

    Hello everyone,

    I found this indicator that gives good buy, sell and exit signals with arrows and other symbol like in the attached image.

    [attachment file=”185170″]

    Please, is there anyone can convert it in prorealtime code?

    Thanks

    //+------------------------------------------------------------------+
    //|                                           SuperSlopeZeroLine.mq4 |
    //| Draw the level line of the super slope in the chart window.      |
    //+------------------------------------------------------------------+
    //2021.11.09 ver 1.00 release.
    //2021.11.09 ver 1.01 Bug fixes case maxBars > Bars.
    //2021.11.09 ver 1.01 The alert function has stopped.
    //2021.11.10 ver 1.02 Bug fixes get close count.
    //2021.11.11 ver 1.03 The alert function is working.
    //2021.11.15 ver 1.04 Bug fixes MTF function.
    //2021.11.15 ver 1.04 Output the reason why the line is not drawn to the expert log.
    //2021.11.15 ver 1.04 Changed the default value.
    //2021.11.15 ver 1.04 Select drawing timing.
    //2021.11.19 ver 1.05 Bug fixes Gold line does not redraw.
    //2022.01.03 ver 1.10 Draw level line.
    //                    Inputs => Level Line inputs. 
    //                    Default value is Do not work.
    //2022.01.08 ver 1.20 The color of the line is strong / weak level or cross-up / down.
    //                    Inputs => Zero Line inputs. 
    //                    Default value is cross-up / down both are Gold color.
    
    #define ver                                 "1.20"
    
    #property copyright                         "sukesuke"
    #property link                              ""
    #property version                           ver
    #property strict
    #property indicator_chart_window
    #property indicator_buffers                 5
    
    enum ENUM_DRAWING_TIMING {
        ON_TICK                                 = 1,  //On Tick
        ON_TIMER                                = 2   //On Timer 1 second
    };
    
    extern string   gen                         = "----General Inputs----"; //----
    extern ENUM_DRAWING_TIMING  DrawingTiming   = ON_TICK;
    extern int      maxBars                     = 2000;
    extern ENUM_TIMEFRAMES  userTimeFrame       = PERIOD_CURRENT; //M1,M5,M30,H1,H4,D1,W1,MN1 
    
    extern string   spac756                     = "---- Slope Inputs ----"; //----
    extern double   entryLevelCrossValue        = 0.5;
    extern double   exitLevelCrossValue         = 0.5;
    extern int      SlopeMAPeriod               = 7;
    extern int      SlopeATRPeriod              = 50;
    
    extern string   spac754                     = "---- Send Alerts ----"; //----
    extern bool     sendEntryLevelCrossAlerts   = false;
    extern bool     sendExitLevelCrossAlerts    = false;
    extern bool     PopupAlert                  = false;
    extern bool     EmailAlert                  = false;
    extern bool     PushAlert                   = false;
    
    extern string   gen2                        = "----Arrow Display----"; //----
    extern bool     showEntryArrows             = false;
    extern bool     showExitArrows              = false;
    extern color    BuyArrowColor               = clrGreen;
    extern int      BuyArrowFontSize            = 16;
    extern color    SellArrowColor              = clrTomato;
    extern int      SellArrowFontSize           = 16;
    extern color    ExitArrowColor              = clrGold;
    extern int      ExitArrowFontSize           = 16;
    
    extern string   zeroline                    = "----Zero Line inputs----"; //----
    extern bool     showZeroLine                = true;
    extern color    LineColorStrongCrossUp      = clrGold;
    extern int      LineWidthStrongCrossUp      = 2;
    extern int      LineStyleStrongCrossUp      = 0;
    extern color    LineColorNormal             = clrWhite;
    extern int      LineWidthNormal             = 2;
    extern int      LineStyleNormal             = 0;
    extern color    LineColorStrongCrossDown    = clrGold;
    extern int      LineWidthStrongCrossDown    = 2;
    extern int      LineStyleStrongCrossDown    = 0;
    
    extern string   levelline                   = "----Level Line inputs----"; //----
    extern bool     showLevelLine               = false;
    extern double   LevelLineValue              = 0.5;
    extern color    LevelLineColor              = clrGold;
    extern int      LevelLineWidth              = 1;
    extern int      LevelLineStyle              = 2;
    
    extern string   disp                        = "----Display Inputs----"; //----
    extern bool     showSlopeValues             = false;
    extern color    colorSlopeValues            = clrWhite;
    extern int      displayTextSize             = 16;
    extern int      horizontalOffset            = 10;
    extern int      verticalOffset              = 5;
    extern int      horizontalShift             = 2;
    extern int      verticalShift               = 0;
    extern string   displayTextFont             = "Lucida Console";
    
    //global variables
    const string    indicatorName               = "SuperSlopeZeroLine";
    const int       windex                      = 0;
    
    bool            _BrokerHasSundayCandles;
    int             ATRPeriodArrows             = 20;
    double          ATRMultiplierArrows         = 1.5;
    string          BuySellArrowFont            = "Wingdings 3";
    string          ExitArrowFont               = "Wingdings 2";
    uchar           BuyArrowStyle               = 219;
    uchar           SellArrowStyle              = 220;
    uchar           ExitArrowStyle              = 80;
    
    bool            CanDraw;
    string          userTimeFrameString;
    string          ObjSuff;
    
    double          closeBuffer[];
    double          slopeBuffer[];
    double          slopeZeroLineNormalBuffer[];
    double          slopeZeroLineStrongCrossUpBuffer[];
    double          slopeZeroLineStrongCrossDownBuffer[];
    double          slopeLevelLinePlusBuffer[];
    double          slopeLevelLineMinusBuffer[];
    
    int             cantDrawPeriod;
    int             limitMTF;
    int             limitCurrent;
    
    double          Lowest;
    double          Highest;
    
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int OnInit() {
    //
        CanDraw = false;
    //
    // indicator Name
        userTimeFrameString = timeframeStringBy(userTimeFrame);
        string shortName = indicatorName + "-" + userTimeFrameString;
        IndicatorShortName(shortName);
    //
        ObjSuff = "_" + userTimeFrameString + "_SSZL";
    //
    // draw time frame
        if (userTimeFrame == PERIOD_CURRENT) {
            userTimeFrame = (ENUM_TIMEFRAMES)_Period;
        }
        if (userTimeFrame < _Period) {
            CanDraw = false;
            Print("@@@@@ TimeFrame = ", userTimeFrameString, " , warning, Can't Draw, userTimeFrame < Period.");
            return(INIT_SUCCEEDED);
        }
    //
    // draw bars count
        if (maxBars > Bars) {
            maxBars = Bars;
        }
        cantDrawPeriod = MathMax(SlopeMAPeriod, SlopeATRPeriod + 11);
        if(maxBars <= cantDrawPeriod) {
            CanDraw = false;
            Print("@@@@@ TimeFrame = ", userTimeFrameString, " , warning, Can't Draw, Not enough maxBars.");
            return(INIT_SUCCEEDED);
        }
        limitCurrent = maxBars;
        limitMTF = iBarShift(NULL, userTimeFrame, Time[limitCurrent - 1]);
        limitMTF = MathMax(limitMTF, cantDrawPeriod) + 1;
    //
    // check draw bars count
        CanDraw = false;
        for (int i = limitCurrent - 1; i > 0; i--) {
            int MTFBar = iBarShift(NULL, userTimeFrame, Time[i]);
            int pLimitCurrent = iBarShift(NULL, 0, iTime(NULL, userTimeFrame, MTFBar));
            if (pLimitCurrent <= limitCurrent) {
                CanDraw = true;
                limitCurrent = pLimitCurrent + 1;
                break;
            }
        }
        if (!CanDraw) {
            Print("@@@@@ TimeFrame = ", userTimeFrameString, " , warning, Can't Draw, Not enough bars.");
            return(INIT_SUCCEEDED);
        }
    //
    // binary search range
        int lowestShift = iLowest(NULL, userTimeFrame, MODE_LOW, limitMTF, 0);
        Lowest = iLow(NULL, userTimeFrame, lowestShift);
        int highestShift = iHighest(NULL, userTimeFrame, MODE_HIGH, limitMTF, 0);
        Highest = iHigh(NULL, userTimeFrame, highestShift);
        Lowest = Lowest - (_Point * 1000);
        Highest = Highest + (_Point * 1000);
    //
    // slope
        _BrokerHasSundayCandles = false;
        for (int i = 0; i < 8; i++) {
            if ( TimeDayOfWeek( iTime( NULL, PERIOD_D1, i ) ) == 0 ) {
                _BrokerHasSundayCandles = true;
                break;
            }
        }
    //
    // buffer
        ArraySetAsSeries(closeBuffer, true);
        ArrayResize(closeBuffer, limitMTF);
        ArrayInitialize(closeBuffer, EMPTY_VALUE);
    
        ArraySetAsSeries(slopeBuffer, true);
        ArrayResize(slopeBuffer, limitCurrent);
        ArrayInitialize(slopeBuffer, EMPTY_VALUE);
    
        SetIndexBuffer(0, slopeZeroLineNormalBuffer);
        SetIndexStyle(0, DRAW_LINE, LineStyleNormal, LineWidthNormal, LineColorNormal);
        SetIndexEmptyValue(0, EMPTY_VALUE);
        ArrayInitialize(slopeZeroLineNormalBuffer, EMPTY_VALUE);
    
        SetIndexBuffer(1, slopeZeroLineStrongCrossUpBuffer);
        SetIndexStyle(1, DRAW_LINE, LineStyleStrongCrossUp, LineWidthStrongCrossUp, LineColorStrongCrossUp);
        SetIndexEmptyValue(1, EMPTY_VALUE);
        ArrayInitialize(slopeZeroLineStrongCrossUpBuffer, EMPTY_VALUE);
    
        SetIndexBuffer(2, slopeZeroLineStrongCrossDownBuffer);
        SetIndexStyle(2, DRAW_LINE, LineStyleStrongCrossDown, LineWidthStrongCrossDown, LineColorStrongCrossDown);
        SetIndexEmptyValue(2, EMPTY_VALUE);
        ArrayInitialize(slopeZeroLineStrongCrossDownBuffer, EMPTY_VALUE);
    
        SetIndexBuffer(3, slopeLevelLinePlusBuffer);
        SetIndexStyle(3, DRAW_LINE, LevelLineStyle, LevelLineWidth, LevelLineColor);
        SetIndexEmptyValue(3, EMPTY_VALUE);
        ArrayInitialize(slopeLevelLinePlusBuffer, EMPTY_VALUE);
    
        SetIndexBuffer(4, slopeLevelLineMinusBuffer);
        SetIndexStyle(4, DRAW_LINE, LevelLineStyle, LevelLineWidth, LevelLineColor);
        SetIndexEmptyValue(4, EMPTY_VALUE);
        ArrayInitialize(slopeLevelLineMinusBuffer, EMPTY_VALUE);
    //
        return(INIT_SUCCEEDED);
    }
    
    
    //+------------------------------------------------------------------+
    //| Custom indicator deinitialization function                       |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason) {
    //
        if (DrawingTiming == ON_TIMER) {
            EventKillTimer();
        }
    //
        for(int i = ObjectsTotal() - 1; i >= 0; i--) {
            if(StringFind(ObjectName(i), ObjSuff, 0) > 0) {
                ObjectDelete(ObjectName(i));
            }
        }
    //
        ArrayFree(closeBuffer);
        ArrayFree(slopeBuffer);
    }
    
    
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    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[]) {
    //
        if (!CanDraw) {
            return 0;
        }
    
        if (prev_calculated > 0) {
            if (DrawingTiming == ON_TICK) {
                //
                DrawChart();
            }
        } else {
            // INIT
            DrawChartForInit();
            //
            if (DrawingTiming == ON_TIMER) {
                EventSetTimer(1);
            }
        }
        return(rates_total);
    }
    
    
    //+------------------------------------------------------------------+
    //| Timer function                                                   |
    //+------------------------------------------------------------------+
    void OnTimer() {
    //
        DrawChart();
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void DrawChartForInit() {
    //
        int pLimitMTF = limitMTF;
        int pLimitCurrent = limitCurrent - cantDrawPeriod - 1;
    //
        DrawChartMain(pLimitMTF, pLimitCurrent);
    //
    // get close (reset)
        ArrayInitialize(closeBuffer, EMPTY_VALUE);
        for(int bar = 0; bar < pLimitMTF; bar++) {
            closeBuffer[bar] = iClose(NULL, userTimeFrame, bar);
        }
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void DrawChart() {
    //
    //TODO mtf 1 bar update //2021.11.?? ver 1.?? Improve response.
    //
        int pLimitMTF = limitMTF;
        int pLimitCurrent = limitCurrent - cantDrawPeriod - 1;
    //
        DrawChartMain(pLimitMTF, pLimitCurrent);
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void DrawChartMain(int pLimitMTF, int pLimitCurrent) {
    //
    // get close
        for(int bar = 0; bar < pLimitMTF; bar++) {
            closeBuffer[bar] = iClose(NULL, userTimeFrame, bar);
        }
    //
    // get slope
        int barOld = -1;
        double slope = 0.0;
        for(int i = 0; i < pLimitCurrent; i++) {
            int bar = iBarShift(NULL, userTimeFrame, Time[i]);
            if (bar != barOld) {
                barOld = bar;
                slope = GetSlope(bar);
            }
            slopeBuffer[i] = slope;
        }
    //
        for(int i = 0; i < pLimitCurrent; i++) {
            ShowArrows(i);
        }
        ShowComments(0);
        SendAlerts(1);
    //
    // get zero line
    //
        if (showZeroLine) {
    //
            barOld = -1;
            double slopeZeroLine = 0.0;
            for(int i = 0; i < pLimitCurrent; i++) {
                int bar = iBarShift(NULL, userTimeFrame, Time[i]);
                if (bar != barOld) {
                    barOld = bar;
                    slopeZeroLine = GetSlopeLevelLine(bar, 0.0);
                }
                // get zero line Normal
                slopeZeroLineNormalBuffer[i] = slopeZeroLine;
                // get zero line Strong
                slopeZeroLineStrongCrossUpBuffer[i] = EMPTY_VALUE;
                if (slopeBuffer[i] > MathMax(entryLevelCrossValue, exitLevelCrossValue)) {
                    slopeZeroLineStrongCrossUpBuffer[i] = slopeZeroLineNormalBuffer[i];
                } else if (slopeBuffer[i] < MathMax(entryLevelCrossValue, exitLevelCrossValue) * -1) {
                    slopeZeroLineStrongCrossDownBuffer[i] = slopeZeroLineNormalBuffer[i];
                }
            }
        }
    //
    // get level line
    //
        if (showLevelLine) {
    //
            for(int bar = 0; bar < pLimitMTF; bar++) {
                closeBuffer[bar] = iClose(NULL, userTimeFrame, bar);
            }
    //
            barOld = -1;
            double slopeLevelLine = 0.0;
            for(int i = 0; i < pLimitCurrent; i++) {
                int bar = iBarShift(NULL, userTimeFrame, Time[i]);
                if (bar != barOld) {
                    barOld = bar;
                    slopeLevelLine = GetSlopeLevelLine(bar, LevelLineValue);
                }
                slopeLevelLinePlusBuffer[i] = slopeLevelLine;
            }
    //
            for(int bar = 0; bar < pLimitMTF; bar++) {
                closeBuffer[bar] = iClose(NULL, userTimeFrame, bar);
            }
    //
            barOld = -1;
            slopeLevelLine = 0.0;
            for(int i = 0; i < pLimitCurrent; i++) {
                int bar = iBarShift(NULL, userTimeFrame, Time[i]);
                if (bar != barOld) {
                    barOld = bar;
                    slopeLevelLine = GetSlopeLevelLine(bar, -LevelLineValue);
                }
                slopeLevelLineMinusBuffer[i] = slopeLevelLine;
            }
        }
    //
        ChartRedraw();
    }
    
    
    //+------------------------------------------------------------------+
    //| binary search
    //+------------------------------------------------------------------+
    double GetSlopeLevelLine(int pShift, double target) {
    //
        double left = Lowest;
        double right = Highest;
        double middle = 0.0;
    //
        while(left <= right) {
    //
            middle = NormalizeDouble((left + right) / 2, _Digits);
            closeBuffer[pShift] = middle;
            double slopeZeroLine = NormalizeDouble(GetSlope(pShift), 3);
    
            if (slopeZeroLine == target) {
                return middle;
            } else if (target < slopeZeroLine) {
                right = NormalizeDouble(middle - _Point, _Digits);
            } else {
                left = NormalizeDouble(middle + _Point, _Digits);
            }
        }
        return middle;
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    double GetSlope(int pShift) {
    //
        double dblTma, dblPrev;
        int shiftWithoutSunday = pShift;
        if ( _BrokerHasSundayCandles && PERIOD_CURRENT == PERIOD_D1 ) {
            if ( TimeDayOfWeek( iTime( NULL, PERIOD_D1, pShift ) ) == 0  ) shiftWithoutSunday++;
        }
    //
        double atr = iATR( NULL, userTimeFrame, SlopeATRPeriod, shiftWithoutSunday + 10 ) / 10;
        double result = 0.0;
        if ( atr != 0 ) {
            dblTma = iMAOnArray(closeBuffer, 0, SlopeMAPeriod, 0, MODE_LWMA, shiftWithoutSunday );
            dblPrev = ( iMAOnArray(closeBuffer, 0, SlopeMAPeriod, 0, MODE_LWMA, shiftWithoutSunday + 1 ) * 231 + closeBuffer[shiftWithoutSunday] * 20) / 251;
    
            result = ( dblTma - dblPrev ) / atr;
        }
    //
        return ( result );
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void ShowArrows(int pShift) {
    
        if(showEntryArrows || showExitArrows) {
            double   ATR = 0, ArrowHigh = 0, ArrowLow = 0;
            ATR = iATR(_Symbol, _Period, ATRPeriodArrows, pShift);
            ArrowHigh = iHigh(_Symbol, _Period, pShift) + ATR * ATRMultiplierArrows;
            ArrowLow = iLow(_Symbol, _Period, pShift) - ATR * ATRMultiplierArrows;
            string ObjSuffString = TimeToString(iTime(NULL, 0, pShift), TIME_DATE) + "_" + TimeToString(iTime(NULL, 0, pShift), TIME_MINUTES) + ObjSuff;
            string objectBuyName = "Buy Arrow " + ObjSuffString;
            string objectSellName = "Sell Arrow " + ObjSuffString;
            string objectExitName = "Exit Arrow " + ObjSuffString;
            if (pShift == 0) {
                ObjectDelete(objectBuyName);
                ObjectDelete(objectSellName);
                ObjectDelete(objectExitName);
            }
            if (showEntryArrows) {
                //Buy
                if (slopeBuffer[pShift + 1] < entryLevelCrossValue && slopeBuffer[pShift] > entryLevelCrossValue) {
                    if(ObjectFind(objectBuyName) == -1) {
                        TextCreate(objectBuyName, iTime(NULL, 0, pShift), ArrowLow, CharToString(BuyArrowStyle), BuyArrowColor, ANCHOR_LOWER, BuySellArrowFont, BuyArrowFontSize);
                    }
                }
                //Sell
                if (slopeBuffer[pShift + 1] > -entryLevelCrossValue && slopeBuffer[pShift] < -entryLevelCrossValue) {
                    if(ObjectFind(objectSellName) == -1) {
                        TextCreate(objectSellName, iTime(NULL, 0, pShift), ArrowHigh, CharToString(SellArrowStyle), SellArrowColor, ANCHOR_UPPER, BuySellArrowFont, SellArrowFontSize);
                    }
                }
            }
            //Exit
            if (showExitArrows) {
                if (slopeBuffer[pShift + 1] > exitLevelCrossValue && slopeBuffer[pShift] < exitLevelCrossValue) {
                    if(ObjectFind(objectExitName) == -1) {
                        TextCreate(objectExitName, iTime(NULL, 0, pShift), ArrowHigh, CharToString(ExitArrowStyle), ExitArrowColor, ANCHOR_UPPER, ExitArrowFont, ExitArrowFontSize);
                    }
                }
                if (slopeBuffer[pShift + 1] < -exitLevelCrossValue && slopeBuffer[pShift] > -exitLevelCrossValue) {
                    if(ObjectFind(objectExitName) == -1) {
                        TextCreate(objectExitName, iTime(NULL, 0, pShift), ArrowLow, CharToString(ExitArrowStyle), ExitArrowColor, ANCHOR_UPPER, ExitArrowFont, ExitArrowFontSize);
                    }
                }
            }
        }
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void ShowComments(int pShift) {
    
        if(pShift == 0 && showSlopeValues) {
            //header
            string objectHeaderName = "column1_tf" + ObjSuff;
            if(ObjectFind(objectHeaderName) == -1) {
                if(ObjectCreate(objectHeaderName, OBJ_LABEL, windex, 0, 0)) {
                    ObjectSet(objectHeaderName, OBJPROP_CORNER, 1);
                    ObjectSet(objectHeaderName, OBJPROP_XDISTANCE, horizontalOffset + horizontalShift * 38);
                    ObjectSet(objectHeaderName, OBJPROP_YDISTANCE, verticalOffset + verticalShift);
                    ObjectSet(objectHeaderName, OBJPROP_HIDDEN, true);
                }
            }
            ObjectSetText(objectHeaderName, userTimeFrameString, displayTextSize, displayTextFont, colorSlopeValues);
            //value
            string objectValueName = "column1_value" + ObjSuff;
            if(ObjectFind(objectValueName) == -1) {
                if(ObjectCreate(objectValueName, OBJ_LABEL, windex, 0, 0)) {
                    ObjectSet(objectValueName, OBJPROP_CORNER, 1);
                    ObjectSet(objectValueName, OBJPROP_XDISTANCE, horizontalOffset);
                    ObjectSet(objectValueName, OBJPROP_YDISTANCE, verticalOffset + verticalShift);
                    ObjectSet(objectValueName, OBJPROP_HIDDEN, true);
                }
            }
            ObjectSetText(objectValueName, DoubleToString(slopeBuffer[pShift], 2), displayTextSize, displayTextFont, colorSlopeValues);
        }
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void SendAlerts(int pShift) {
    
    //PopUp alert Stuff
        if (pShift == 1 && IsNewBar()) {
            if(sendEntryLevelCrossAlerts) {
                if(slopeBuffer[pShift + 1] < entryLevelCrossValue && slopeBuffer[pShift] > entryLevelCrossValue) {
                    fireAlerts(_Symbol + " did a level cross up " + DoubleToStr(entryLevelCrossValue, 2) + "  " + userTimeFrameString + " @" + DoubleToStr(Bid, _Digits) + "__" + TimeToStr(TimeCurrent(), TIME_MINUTES));
                } else if(slopeBuffer[pShift + 1] > -entryLevelCrossValue && slopeBuffer[pShift] < -entryLevelCrossValue) {
                    fireAlerts(_Symbol + " did a level cross down " + DoubleToStr(-entryLevelCrossValue, 2) + "  " + userTimeFrameString + " @" + DoubleToStr(Bid, _Digits) + "__" + TimeToStr(TimeCurrent(), TIME_MINUTES));
                }
            }
            if(sendExitLevelCrossAlerts) {
                if(slopeBuffer[pShift + 1] > exitLevelCrossValue && slopeBuffer[pShift] < exitLevelCrossValue) {
                    fireAlerts(_Symbol + " did an 'exit buy' level cross down " + DoubleToStr(exitLevelCrossValue, 2) + "  " + userTimeFrameString + " @" + DoubleToStr(Bid, _Digits) + "__" + TimeToStr(TimeCurrent(), TIME_MINUTES));
                } else if(slopeBuffer[pShift + 1] < -exitLevelCrossValue && slopeBuffer[pShift] > -exitLevelCrossValue) {
                    fireAlerts(_Symbol + " did an 'exit sell' level cross up " + DoubleToStr(-exitLevelCrossValue, 2) + "  " + userTimeFrameString + " @" + DoubleToStr(Bid, _Digits) + "__" + TimeToStr(TimeCurrent(), TIME_MINUTES));
                }
            }
        }
    }
    
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    void fireAlerts(string sMsg) {
        if(PopupAlert)
            Alert(sMsg);
        if(EmailAlert)
            SendMail("Super Slope Zero Line Alert " + "", sMsg);
        if(PushAlert)
            SendNotification(sMsg);
    }
    
    
    //+------------------------------------------------------------------+
    //|
    //+------------------------------------------------------------------+
    void TextCreate(const string            pName = "Text",             // object name
                    datetime                time = 0,                   // anchor point time
                    double                  price = 0,                  // anchor point price
                    const string            text = "Text",              // the text itself
                    const color             clr = clrRed,               // color
                    const ENUM_ANCHOR_POINT anchor = ANCHOR_LEFT_UPPER, // anchor type
                    const string            font = "Wingdings",         // font
                    const int               font_size = 14,             // font size
                    const double            angle = 0.0,                // text slope
                    const bool              back = true,                // in the background
                    const bool              selection = false,          // highlight to move
                    const bool              hidden = true,              // hidden in the object list
                    const long              z_order = 0
                   ) {
        long chart_ID = ChartID();
        string name = pName;
    
        if ( ObjectFind( chart_ID, name ) < 0 ) {
            if ( !ObjectCreate( chart_ID, name, OBJ_TEXT, 0, time, price ) ) {
                Print(__FUNCTION__, ": failed to create "Text" object! Error code = ", GetLastError() );
                return;
            }
        }
    
        ObjectSetString(chart_ID, name, OBJPROP_TEXT, text);
        ObjectSetString(chart_ID, name, OBJPROP_FONT, font);
        ObjectSetInteger(chart_ID, name, OBJPROP_FONTSIZE, font_size);
        ObjectSetDouble(chart_ID, name, OBJPROP_ANGLE, angle);
        ObjectSetInteger(chart_ID, name, OBJPROP_ANCHOR, anchor);
        ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr);
        ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back);
        ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection);
        ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection);
        ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden);
        ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order);
    }
    
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    string timeframeStringBy(ENUM_TIMEFRAMES signalTimeframe) {
        string tf = EnumToString(signalTimeframe);
        StringReplace(tf, "PERIOD_", "");
        if (tf == "CURRENT") {
            ENUM_TIMEFRAMES tf2 = (ENUM_TIMEFRAMES)_Period;
            tf = timeframeStringBy(tf2);
        }
        return tf;
    }
    
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    bool IsNewBar() {
        static datetime firstBarTime = Time[1];
        datetime time0 = iTime(NULL, _Period, 0);
        if(firstBarTime == time0) {
            return false;
        } else {
            firstBarTime = time0;
            return true;
        }
    }
    
    
    //+------------------------------------------------------------------+
    #185172 quote
    Igven
    Participant
    New

    Sorry, the file

    Regards

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Conversion of indicator SuperSlopeZeroLine from MT4


ProBuilder support

New Reply
Author
author-avatar
Igven @igven Participant
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by Igven
4 years ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 01/11/2022
Status: Active
Attachments: 2 files
Logo Logo
Loading...