extern bool TrailingStop = TRUE;
extern double Trailing_Stop_Pips = 50;
extern bool Use_Preceding_TP = FALSE;
extern int Preceding_TP_Pips = 20;
void OnTick()
{
if(TrailingStop){
TrailingPositions();
}
}
void TrailingPositions() {
double l_price_4;
for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
if (OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUY) {
if (Trailing_Stop_Pips > 0) {
if (Bid - OrderOpenPrice() > Point * db * Trailing_Stop_Pips) {
if (OrderStopLoss() < Bid - Point * db * Trailing_Stop_Pips) {
if (Use_Preceding_TP) l_price_4 = Bid + Preceding_TP_Pips * (Point * db);
else l_price_4 = OrderTakeProfit();
OrderModify(Orde
MT4量化编程-跟踪止损范例代码
于 2022-04-24 06:28:39 首次发布