Assista a como baixar robôs de negociação gratuitos
Encontre-nos em Twitter!
Participe de nossa página de fãs
Script interessante?
Coloque um link para ele, e permita que outras pessoas também o avaliem
Você gostou do script?
Avalie seu funcionamento no terminal MetaTrader 5
Scripts

BreakEven Function - script para MetaTrader 4

Visualizações:
6354
Avaliação:
(26)
Publicado:
2022.03.06 08:03
Precisa de um robô ou indicador baseado nesse código? Solicite-o no Freelance Ir para Freelance
//+------------------------------------------------------------------+
//|Breakeven                                                         |
//+------------------------------------------------------------------+
void BreakEven(double _breakEvenPips, bool useSymbol=false, bool useMagicNumber=false, int _magicNumber=0) {
    for(int i=OrdersTotal()-1; i>=0; i--) {
        if(OrderSelect(i,SELECT_BY_POS)) {
            bool magic = (useMagicNumber) ? (OrderMagicNumber()==_magicNumber) : true;
            bool symbol = (useSymbol) ? (OrderSymbol()==Symbol()) : true;
            if(!magic || !symbol) continue;
            if(OrderType() == OP_BUY) {
                if(NormalizeDouble(OrderStopLoss(),_Digits) < NormalizeDouble(OrderOpenPrice(),_Digits)) {
                    if(Bid - OrderOpenPrice() >= NormalizeDouble(_breakEvenPips * Point() * 10,_Digits)) {
                        if(NormalizeDouble(OrderStopLoss(),_Digits) != NormalizeDouble(OrderOpenPrice(),Digits)){
                            ResetLastError();
                            if(!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice(),_Digits), OrderTakeProfit(), 0)) {
                               Print("ERROR:"," Order Modify Failed: ",_LastError,"  ||  Function Name: ",__FUNCTION__,"  ||  Line Number: ",__LINE__);
                            }
                        }
                    }
                }
            }
            
            if(OrderType() == OP_SELL) {
                if(NormalizeDouble(OrderStopLoss(),_Digits) > NormalizeDouble(OrderOpenPrice(),_Digits)) {
                    if(OrderOpenPrice() - Bid >= NormalizeDouble(_breakEvenPips * Point() * 10,_Digits)) {
                        if(NormalizeDouble(OrderStopLoss(),_Digits) != NormalizeDouble(OrderOpenPrice(),_Digits)) {
                            ResetLastError();
                            if(!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice(),_Digits), OrderTakeProfit(), 0)) {
                                Print("ERROR:"," Order Modify Failed: ",_LastError,"  ||  Function Name: ",__FUNCTION__,"  ||  Line Number: ",__LINE__);
                            }
                        }
                    }
                }
            }
        }
    }
}
    GARCHV2 GARCHV2

    A second version of GARCH volatility indicator of https://www.mql5.com/en/code/11776.

    Multi Currencies EA CloseAll Multi Currencies EA CloseAll

    Due to recent popularity of Multi currencies EA, This codes allows to Close Orders or delete Pending orders of a Multi Currencies EA, Single Currency EA or Manual orders.

    Adaptive momentum oscillator idea from David Varadi. Adaptive momentum oscillator idea from David Varadi.

    Adaptive momentum oscillator idea from David Varadi.

    MA Angle MA Angle

    Not sure if anyone need this. Just showing the angle of the MA of current and adjacent candle.