extern int BullBearPeriod=5;
extern double lots = 1.0; //
extern double TrailingStop = 15; // trail stop in points
extern double takeProfit = 150; // recomended no more than 150
extern double stopLoss = 45; // do not use s/l
extern double slippage = 3;
extern string nameEA = "DayTrading"; // EA identifier. Allows for several co-existing EA with different values
double bull,bear;
double PrevBBE,CurrentBBE;
double realTP, realSL,b,s,sl,tp;
bool isBuying = false, isSelling = false, isClosing = false;
int cnt, ticket;
int init() {
// код доступен только после оплаты
}
int deinit() {
return(0);
}
int start() {
// код доступен только после оплаты
}
if(Bars < 200) {
Print("Not enough bars for this strategy - ", nameEA);
return(-1);
}
calculateIndicators(); // Calculate indicators' value
int totalOrders = OrdersTotal();
int numPos = 0;
for(cnt=0; cnt<totalOrders; cnt++) { // scan all orders and positions...
OrderSelect(cnt, SELECT_BY_POS); // the next line will check for ONLY market trades, not entry orders
if(OrderSymbol() == Symbol() && OrderType() <= OP_SELL ) { // only look for this symbol, and only orders from this EA
numPos++;
if(OrderType() == OP_BUY) { // Check for close signal for bought trade
if(TrailingStop > 0) { // Check trailing stop
if(Bid-OrderOpenPrice() > TrailingStop*Point)
{
if(OrderStopLoss() < (Bid - TrailingStop*Point))
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Blue);
}
}
} else { // Check sold trade for close signal
if(TrailingStop > 0) { // Control trailing stop
if(OrderOpenPrice() - Ask > TrailingStop*Point)
{
if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStop*Point)
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Red);
}
}
}
}
}
if(numPos < 1) {
if(AccountFreeMargin() < 1000*lots) {
Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA);
return(0);
Показано первые 50% кода (символов: 3291)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.