//+------------------------------------------------------------------+
//| ProjectName |
//| Copyright 2018, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
extern int BE_Point = 10;
extern int BE_Active_Point = 25;
bool OM;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
CheckSellbetop();
CheckBuybetop();
}
//+------------------------------------------------------------------+
void CheckSellbetop()
{
for(int be = OrdersTotal() - 1; be >= 0; be--)
{
if(OrderSelect(be, SELECT_BY_POS, MODE_TRADES))
if(OrderSymbol() == Symbol())
if(OrderType() == OP_SELL)
if(OrderStopLoss() > OrderOpenPrice())
if(Bid < OrderOpenPrice() - BE_Point * _Point)
{
OM = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - BE_Active_Point * _Point, OrderTakeProfit(), 0, CLR_NONE);
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CheckBuybetop()
{
for(int be = OrdersTotal() - 1; be >= 0; be--)
{
if(OrderSelect(be, SELECT_BY_POS, MODE_TRADES))
if(OrderSymbol() == Symbol())
if(OrderType() == OP_BUY)
if(OrderStopLoss() < OrderOpenPrice())
if(Ask > OrderOpenPrice() + BE_Point * _Point)
{
OM = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BE_Active_Point * _Point, OrderTakeProfit(), 0, CLR_NONE);
}
}
}
//+------------------------------------------------------------------+
void BE_HEHE()
{
for(int be = OrdersTotal() - 1; be >= 0; be--)
{
if(!OrderSelect(be, SELECT_BY_POS, MODE_TRADES))
continue;
//if(OrderSymbol() == Symbol()) //Kiểm tra chỗ này sai bét!!
if(OrderType() == OP_SELL)
{
if(OrderStopLoss() > OrderOpenPrice())
if(Bid < OrderOpenPrice() - BE_Point * _Point)
{
OM = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - BE_Active_Point * _Point, OrderTakeProfit(), 0, CLR_NONE);
}
}
//--
if(OrderType() == OP_BUY)
{
if(OrderStopLoss() < OrderOpenPrice())
if(Ask > OrderOpenPrice() + BE_Point * _Point)
{
OM = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BE_Active_Point * _Point, OrderTakeProfit(), 0, CLR_NONE);
}
}
} //end FOR loop
}
//+------------------------------------------------------------------+
BEcheck
Cuongitl 1,711 4th Sep, 2020
To share this paste please copy this url and send to your friends
RAW Paste Data
-
Cuongitl - 3 years ago
add BE_HEHE