//+------------------------------------------------------------------+
//| 收盘价.mq4 |
//| Copyright 2021, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
int sun=300;
int ying=300;
double ma11=iMA(Symbol(),0,12,0,MODE_EMA,PRICE_CLOSE,1);
double k=iStochastic(Symbol(),0,89,34,5,MODE_SMA,0,MODE_MAIN,0);
double d=iStochastic(Symbol(),0,89,34,5,MODE_SMA,0,MODE_SIGNAL,0);
if((Close[1]<ma11)&&(Close[2]>ma11))
{
if(d>k)
{
if(OrdersTotal()==0)
{
int ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Bid+sun*Point,Bid-ying*Point,Symbol()+"sell",16384,0,Red);
}
}
}
if((Close[1]>ma11)&&(Close[2]<ma11))
{
if(k>d)
{
if(OrdersTotal()==0)
{
int ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-sun*Point,Ask+ying*Point,Symbol()+"buy",16384,0,Yellow);
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{
//---
double ret=0.0;
//---
//---
return(ret);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
|