//+------------------------------------------------------------------+
//| jjjj.mq4 |
//| Copyright 2022, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int i = 0;
int hourTemp = 0;
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
int startHour = 7;
int sybolra = 10;
double lots = 0.1;
void OnTick()
{
int hour = Hour();
if (hour == (startHour+1)) {
double high1 = iHigh(Symbol(),PERIOD_H1,1);
double high2 = iHigh(Symbol(),PERIOD_H1,2);
double high3 = iHigh(Symbol(),PERIOD_H1,3);
high = MathMax(MathMax(high1, high2), high3);
double low1 = iLow(Symbol(),PERIOD_H1,1);
double low2 = iLow(Symbol(),PERIOD_H1,2);
double low3 = iLow(Symbol(),PERIOD_H1,3);
low = MathMin(MathMin(low1, low2), low3);
}
if (hourTemp == startHour && hour > startHour){
//if (hourTemp>hour) {
sendGubiyu();
return;
}
hourTemp = hour;
Comment("我的EA: "+i++
+"\n\r"+ "单子数量: "+ OrdersTotal()
+"\n\r"+ "浮动盈亏: "+ AccountProfit()
+"\n\r"+ "服务器时间: "+ Hour()
+"\n\r"+ "北京时间: "+ TimeHour(TimeLocal())
+"\n\r"+ "账户余额: "+ AccountEquity());
}
//+------------------------------------------------------------------+
double high;
double low;
void sendGubiyu(){
double offset = high - low;
if (offset <(3/sybolra)){
offset = 3/sybolra;
}
if(Ask > high){
OrderSend(Symbol(),OP_BUY, lots, Ask, 3, high - offset, 2*offset +high, "mybuy", 0,0, clrGreen);
hourTemp = Hour();
} else if (Bid < low){
OrderSend(Symbol(),OP_SELL, lots, Bid, 3, low + offset, low - 2*offset , " mysell", 0, 0, clrGreen);
hourTemp = Hour();
}
}