1 Star 1 Fork 1

chizhijing / MT4

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
czj_ea3.mq4 5.07 KB
一键复制 编辑 原始数据 按行查看 历史
chizhijing 提交于 2016-10-10 18:34 . MQL4 INIT
//+------------------------------------------------------------------+
//| czj_ea3.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern double N=20;
extern double TakeProfit=50;//止盈点数
extern double StopLoss=20;//止损点数
extern double Lots=0.1;//交易手数
extern double Poin;//平台最小报价
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//统一不同币种最小报价单位
if(Point==0.00001) Poin=0.0001;
else if(Point==0.001) Poin=0.01;
else Poin=Point;
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//计算上线和下线
double upLine=0;
double downLine=1000000;
for(int i=1;i<N;i++)
{
upLine=MathMax(upLine,iHigh(NULL,0,i));
downLine=MathMin(downLine,iLow(NULL,0,i));
}
//股价高于上线,买入,平掉卖单
if(iClose(NULL,0,0)>upLine)
{
MessageBox("买入");
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES) && OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
if(OrdersTotal()==0)
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Poin,Ask+TakeProfit*Poin,"TFO_1",0,Green);
}
//股价低于下线,卖出,平掉买单
if(iClose(NULL,0,0)<downLine)
{
MessageBox("卖出");
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES) && OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
if(OrdersTotal()==0)
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Poin,Bid-TakeProfit*Poin,"TFO_1",0,Red);
}
}
//+------------------------------------------------------------------+
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chizhijing/MT4.git
git@gitee.com:chizhijing/MT4.git
chizhijing
MT4
MT4
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891