//+------------------------------------------------------------------+
//| 收盘价.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);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
前一k线下穿12周期ema均线并且参数为 89 43 5的kdj指标d k 开卖单,止损止盈都设为300
一般我写的时候还要考虑点差,会这样写
ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Ask+sun*Point,Bid-ying*Point,Symbol()+ sell ,16384,0,Red);
条件上你可以再判断一下均线的方向,或者kdj线的方向
商品属性 []
商品标签