Files
xMQL4/Docs/Samples/DrawSignal.md
T
2024-01-25 04:03:36 +03:30

2.0 KiB

Draw Signal

    //
    //  Draw a shape On Chart ...
    if (hasLongSignal) {
        //
        arrowups++;

        //
        string arrowUpName = StringConcatenate(signalPrefix, "_ArrowUp_", arrowups);

        //
        datetime arrowTime = iTime(
            _Symbol, 
            _Period, 
            bar_index
        );

        //
        double arrowPrice = iOpen(
            _Symbol,
            _Period,
            bar_index
        );
        arrowPrice = arrowPrice - (100 * _Point);

        //
        // Draw Signal Arrow Shape ...
        bool isDraw = DrawArrow(
            0,
            arrowUpName,
            0,
            arrowTime,
            arrowPrice,
            SYMBOL_ARROWUP,
            ANCHOR_BOTTOM,
            clrAqua,
            STYLE_SOLID,
            3,
            false,
            false,
            false,
            0
        );

        //
        // SL Info ...
        XSLInfo slInfo = GetSwngSL(bar_index);

        //
        // TP Info ...
        XTPInfo tpInfo = GetTP(bar_index);


        //
        string arrowUpSLName = StringConcatenate(signalPrefix, "_SL_", arrowups);
        string arrowUpTPName = StringConcatenate(signalPrefix, "_TP_", arrowups);

        //
        datetime time1 = iTime(
            _Symbol,
            _Period,
            bar_index + 1
        );
        datetime time2 = iTime(
            _Symbol,
            _Period,
            bar_index
        );

        //
        // Draw Signal SL ...
        DrawTrendLine(
            0,
            arrowUpSLName,
            0,
            time1,
            slInfo.longSL,
            time2,
            slInfo.longSL,
            clrFuchsia,
            STYLE_SOLID,
            2
        );

        //
        // Draw Signal TP ...
        DrawTrendLine(
            0,
            arrowUpTPName,
            0,
            time1,
            tpInfo.longTP,
            time2,
            tpInfo.longTP,
            clrAqua,
            STYLE_SOLID,
            2
        );
    }