You are on page 1of 1

PD

F -X C h a n ge

PD

F -X C h a n ge

O W !

//+------------------------------------------------------------------+ //| TralingStop.mq4 | //| Copyright 2005, Cleon Adonis Santos | tr re a c //| www.fw380.com | k e r- s o ft w a //+------------------------------------------------------------------+ #property copyright "Copyright 2005, Cleon Adonis Santos" #property link "www.fw380.com/forex"
N y bu to
om

to
ww

bu

O W ! C
tr
ac

.c

k e r- s o ft w a

re

extern int extern int double

BarsNum = 5; PipDistance = 1; LTS, STS, Spread;

int start() { int count = 0; // ----- Spread calculation ----Spread = MarketInfo(Symbol(), MODE_SPREAD) * Point; // ----- Stop Loss Calculation ----LTS = NormalizeDouble(Low[Lowest(NULL, 0, MODE_LOW, BarsNum, 1)] - (PipDistance * Point), Digits); STS = NormalizeDouble(High[Highest(NULL, 0, MODE_HIGH, BarsNum, 1)] + Spread + (PipDistance * Point), Digits); Comment("LTS: ", LTS, " - STS: ", STS); if (OrdersTotal() != 0) { while (count < OrdersTotal()) { OrderSelect(count, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY && (LTS > OrderStopLoss() || OrderStopLoss() == 0)) { OrderModify(OrderTicket(), 0, LTS, 0, 0, Blue); Alert("OP_BUY Error: ", GetLastError(), " - ", LTS, " - ", OrderTicket()); } if (OrderType() == OP_SELL && (STS < OrderStopLoss() || OrderStopLoss() == 0)) { OrderModify(OrderTicket(), 0, STS, 0, 0, Red); Alert("OP_SELL Error: ", GetLastError(), " - ", STS, " - ", OrderTicket()); } if (OrderType() == OP_BUYSTOP && (LTS > OrderStopLoss() || OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), LTS, 0, 0, Blue); Alert("OP_BUYSTOP Error: ", GetLastError(), " - ", LTS, " - ", OrderTicket()); } if (OrderType() == OP_SELLSTOP && (STS < OrderStopLoss() || OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), STS, 0, 0, Red); Alert("OP_SELLSTOP Error: ", GetLastError(), " - ", STS, " - ", OrderTicket()); } } count++; } } return(0); }

Page 1/1

.c

ww
w

om

lic

lic
.

You might also like