input int TakeProfit = 5;
input double Lots = 0.01;
input int MagicNumber = 12345;
input bool Weekend_Stop = true;
input int Stop_Day_Of_Week1 = 1;
input int Stop_Day_Of_Week2 = 5;
input int Stop_Hours = 14;
int OnInit() {
return (INIT_SUCCEEDED);
}
void OnDeinit(const int reason) {
}
void OnTick() {
double kakoMA50, kakoMA100;
double genMA50, genMA100;
kakoMA50 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, 1);
kakoMA100 = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, 1);
genMA50 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, 0);
genMA100 = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, 0);
int NowTime = TimeHour(TimeCurrent());
bool OderStop = False;
if (Weekend_Stop == true && NowTime >= Stop_Hours) {
if (DayOfWeek() == Stop_Day_Of_Week1 || DayOfWeek() == Stop_Day_Of_Week2) {
OderStop = true;
}
}
if (kakoMA50 <= kakoMA100 && genMA50 > genMA100 && OderStop == False) {
OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, Ask + TakeProfit * Point * 10, "Order Long", MagicNumber, 0, Red);
}
if (kakoMA50 >= kakoMA100 && genMA50 < genMA100 && OderStop == False) {
OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, 0, Bid - TakeProfit * Point * 10, "Order Short", MagicNumber, 0, Blue);
}
}
暂无评论