MT4EA_初级简单编写挂单EA_ 柒侠伍义_李易俸_2017
本帖最后由 柒侠伍义 于 2017-3-4 15:26 编辑主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第00章:初级挂单编写000.mq4
//+------------------------------------------------------------------+
//| 初级挂单编写000.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
//+------------------------------------------------------------------+
//| 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()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
少说多动手
是学会编写硬道理
000未完
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第01章:初级挂单编写001.mq4
//+------------------------------------------------------------------+
//| 初级挂单编写000.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
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);//修改成1秒,EA跑1次
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
002
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第02章:初级挂单编写002.mq4
//+------------------------------------------------------------------+
//| 初级挂单编写000.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
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
挂单编写001(); //子程式
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
void 挂单编写001(){
}//end
002未完
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第03章:初级挂单编写003.mq4
//+------------------------------------------------------------------+
//| 初级挂单编写.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
#include "子程式BY7X51.mqh"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
挂单编写001(); //子程式
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
void 挂单编写001(){
//---------开始编写---------//
//---------结束编写---------//
}//end
准备完毕
可以开始编写了........
003
为什么是马来西亚?
本帖最后由 柒侠伍义 于 2017-3-4 14:17 编辑
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第04章:学习编写案例001
编写案例001::
开始ea就下注
一个buylimit
一个selllimit
和市场距离120点
注码0.10
没有TP
没有SL
没有TS
如果挂单成交再下注该挂单
如果全部盈利450就关闭全部
资料来源::
有源码
http://bbs.520fx.com/forum.php?m ... 6orderby%3Ddateline
#property link "waddahattar@hotmail.com"
extern int Step=120;
extern doubleFirstLot=0.1;
extern doubleIncLot=0;
extern doubleMinProfit=450;
extern int Magic = 2008;
double gLotSell=0;
double gLotBuy=0;
double LSP,LBP;
int init()
{
Comment("Waddah Attar Win");
GlobalVariableSet("OldBalance",AccountBalance());
return(0);
}
int deinit()
{
Comment("");
return(0);
}
int start()
{
double i;
double sl,p;
if (AccountEquity()>=GlobalVariableGet("OldBalance")+MinProfit)
{
DeletePendingOrders(Magic);
CloseOrders(Magic);
GlobalVariableSet("OldBalance",0);
}
GlobalVariableSet("OldBalance",AccountBalance());
if (MyOrdersTotal(Magic)==0)
{
OrderSend(Symbol(),OP_BUYLIMIT,FirstLot,Ask-Step*Point,3,0,0,"",Magic,0,Green);
OrderSend(Symbol(),OP_SELLLIMIT,FirstLot,Bid+Step*Point,3,0,0,"",Magic,0,Red);
}
LSP=GetLastSellPrice(Magic);
LBP=GetLastBuyPrice(Magic);
if((LSP-Bid)<=5*Point)
{
OrderSend(Symbol(),OP_SELLLIMIT,gLotSell+IncLot,LSP+Step*Point,3,0,0,"",Magic,0,Red);
}
if((Ask-LBP)<=5*Point)
{
OrderSend(Symbol(),OP_BUYLIMIT,gLotBuy+IncLot,LBP-Step*Point,3,0,0,"",Magic,0,Red);
}
return(0);
}
int DeletePendingOrders(int Magic)
{
int total= OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()!=OP_BUY || OrderType()!=OP_SELL))
{
OrderDelete(OrderTicket());
}
}
return(0);
}
int CloseOrders(int Magic)
{
int total= OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}
int MyOrdersTotal(int Magic)
{
int c=0;
int total= OrdersTotal();
for (int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
{
c++;
}
}
return(c);
}
double GetLastBuyPrice(int Magic)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUY))
{
gLotBuy=OrderLots();
return(OrderOpenPrice());
break;
}
}
return(0);
}
double GetLastSellPrice(int Magic)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_SELLLIMIT ||OrderType()==OP_SELL))
{
gLotSell=OrderLots();
return(OrderOpenPrice());
break;
}
}
return(100000);
}
004
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第05章:简单编写案例001
//+------------------------------------------------------------------+
//| 初级挂单编写.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
#include "子程式BY7X51.mqh"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
挂单编写001(); //子程式
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
void 挂单编写001(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
if(OSL==0)//如果没有SELLLIMIT挂单
{
LOTMM=0.10; //注码
SELLLIMIT点数距离=120;
SELLLIMIT线条=1;
SELLLIMIT卖下();//下注SELLLIMIT挂单
}
if(OBL==0) //如果没有BUYLIMIT挂单
{
LOTMM=0.10;
BUYLIMIT点数距离=120;
BUYLIMIT线条=1;
BUYLIMIT买上(); //下注BUYLIMIT挂单
}
//-----出场编写-----------//
if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
//---------结束编写---------//
}//end
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
下载ea
005
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第06章:EA就是这样简单编写
看看别人怎样编写.....
看看柒侠伍义怎样编写....
编写方法完全不同
且有相同的EA效果.
你要学习别人复杂的编写方法
还是学习柒侠伍义简单编写方法呢?
编写技巧复杂。你可能要好几天编写
可能还编写错误丛丛
简单编写
30分钟内搞定.
06未完
本帖最后由 柒侠伍义 于 2017-3-4 15:00 编辑
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第06章:编写技巧不同EA效果相同
如果你会看源码
看看案例001
你会发现作者用AccountBalance
及AccountEquity来出场
而柒侠伍义简单的用AccountProfit出场
这两种有分别吗?
答案:大同小异
看你要的策略
我们可以换这样编写
如果要和作者一样
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
006
本帖最后由 柒侠伍义 于 2017-3-4 15:28 编辑
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第07章:如何回测EA?
1 选择你要 回测的EA
2 选择你要回测的货币对
3 选择你要回测的种类, 通常选择1 或 2 千万不要3
4 选择开始时间
5 选择结束时间
6 选择ea外部参数 通常默认
7 选择你要回测的时段
8 点击 打勾 要观看回测
9 千万不要点击这里
10 以上全部确定 点击开始
如果回测这种结果
表示是不错的效果.
007
本帖最后由 柒侠伍义 于 2017-3-4 17:21 编辑
/*
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第08章:改变策略
如果我们想改变策略
试一试
把 buylimit 和 selllimit
改成 buystop 和 sellstop
其他参数暂时不想改
看看效果...
到底挂单buylimit 和 selllimit 好一些?
还是挂单buystop 和 sellstop好一些?
其实编写非常简单
把名字换一下就可以
但 为了保留策略001
我们把修改的称为002就可以.
*/
double kkkk;
//+------------------------------------------------------------------+
//| 初级挂单编写.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
#include "子程式BY7X51.mqh"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
// 挂单编写001(); //子程式
挂单编写002(); //子程式
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
void 挂单编写001(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSL==0)//如果没有SELLLIMIT挂单
{
LOTMM=0.10; //注码
SELLLIMIT点数距离=120;
SELLLIMIT线条=1;
SELLLIMIT卖下();//下注SELLLIMIT挂单
}
//-----EA 进场编写2------------//
if(OBL==0) //如果没有BUYLIMIT挂单
{
LOTMM=0.10;
BUYLIMIT点数距离=120;
BUYLIMIT线条=1;
BUYLIMIT买上(); //下注BUYLIMIT挂单
}
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
//+------------------------------------------------------------------+
void 挂单编写002(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSS==0)//如果没有SELLSTOP挂单
{
LOTMM=0.10; //注码
SELLSTOP点数距离=120;
SELLSTOP线条=1;
SELLSTOP卖下();//下注SELLSTOP挂单
}
//-----EA 进场编写2------------//
if(OBS==0) //如果没有BUYSTOP挂单
{
LOTMM=0.10;
BUYSTOP点数距离=120;
BUYSTOP线条=1;
BUYSTOP买上(); //下注BUYSTOP挂单
}
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
008
/*
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第09章:提防错误使用
通常在人们都会犯错误
即使低级错误
为了防止误用在live户口
我们编写一些提防
添加编写如下....
*/
double kkkk;
//+------------------------------------------------------------------+
//| 初级挂单编写.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
#include "子程式BY7X51.mqh"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//------防止误用在live户口--------//
if(!IsDemo()){
Alert("不可用在live户口");
ExpertRemove();
return(0);
}
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
// 挂单编写001(); //子程式
挂单编写002(); //子程式
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
void 挂单编写001(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSL==0)//如果没有SELLLIMIT挂单
{
LOTMM=0.10; //注码
SELLLIMIT点数距离=120;
SELLLIMIT线条=1;
SELLLIMIT卖下();//下注SELLLIMIT挂单
}
//-----EA 进场编写2------------//
if(OBL==0) //如果没有BUYLIMIT挂单
{
LOTMM=0.10;
BUYLIMIT点数距离=120;
BUYLIMIT线条=1;
BUYLIMIT买上(); //下注BUYLIMIT挂单
}
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
//+------------------------------------------------------------------+
void 挂单编写002(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSS==0)//如果没有SELLSTOP挂单
{
LOTMM=0.10; //注码
SELLSTOP点数距离=120;
SELLSTOP线条=1;
SELLSTOP卖下();//下注SELLSTOP挂单
}
//-----EA 进场编写2------------//
if(OBS==0) //如果没有BUYSTOP挂单
{
LOTMM=0.10;
BUYSTOP点数距离=120;
BUYSTOP线条=1;
BUYSTOP买上(); //下注BUYSTOP挂单
}
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
支持新作品
本帖最后由 柒侠伍义 于 2017-3-4 22:00 编辑
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第10章:更好的编写方法003
如果我要回测
buystop挂单 + buylimit挂单 ?
是不是还要修改编写??
哈哈和....
这个是当然.
其实作为一名编写
我们就编写比较自由的EA
自己可以研究
别人也可以研究
我们换一个编写技巧及思维
//-----EA 进场编写1------------//
if(OSS==0&&SELLSTOP线条!=0){SELLSTOP卖下();}
if(OSL==0&&SELLLIMIT线条!=0){SELLLIMIT卖下();}
if(OBS==0&&BUYSTOP线条!=0){BUYSTOP买上();}
if(OBL==0&&BUYLIMIT线条!=0){BUYLIMIT买上();}
只要在EA参数画面输入
爱怎样下注就怎样下注
//+------------------------------------------------------------------+
//| 初级挂单编写.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
#include "子程式BY7X51.mqh"
extern double 盈利目标=450;
double kkkk;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//------防止误用在live户口--------//
if(!IsDemo()){
Alert("不可用在live户口");
ExpertRemove();
return(0);
}
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
// 挂单编写001(); //子程式
//挂单编写002(); //子程式
挂单编写003(); //子程式
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
void 挂单编写001(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSL==0)//如果没有SELLLIMIT挂单
{
LOTMM=0.10; //注码
SELLLIMIT点数距离=120;
SELLLIMIT线条=1;
SELLLIMIT卖下();//下注SELLLIMIT挂单
}
//-----EA 进场编写2------------//
if(OBL==0) //如果没有BUYLIMIT挂单
{
LOTMM=0.10;
BUYLIMIT点数距离=120;
BUYLIMIT线条=1;
BUYLIMIT买上(); //下注BUYLIMIT挂单
}
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
//+------------------------------------------------------------------+
void 挂单编写002(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSS==0)//如果没有SELLSTOP挂单
{
LOTMM=0.10; //注码
SELLSTOP点数距离=120;
SELLSTOP线条=1;
SELLSTOP卖下();//下注SELLSTOP挂单
}
//-----EA 进场编写2------------//
if(OBS==0) //如果没有BUYSTOP挂单
{
LOTMM=0.10;
BUYSTOP点数距离=120;
BUYSTOP线条=1;
BUYSTOP买上(); //下注BUYSTOP挂单
}
//-----出场编写-----------//
//if(AccountProfit()>=盈利目标){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=盈利目标+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
void 挂单编写003(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSS==0&&SELLSTOP线条!=0){SELLSTOP卖下();}
if(OSL==0&&SELLLIMIT线条!=0){SELLLIMIT卖下();}
if(OBS==0&&BUYSTOP线条!=0){BUYSTOP买上();}
if(OBL==0&&BUYLIMIT线条!=0){BUYLIMIT买上();}
//-----出场编写-----------//
//if(AccountProfit()>=450){关闭全部();} //户口盈利450就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=450+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
//------------------------------//
主题:: MT4EA_初级编写挂单EA_ 柒侠伍义_李易俸_2017
原创:: 李易俸(柒侠伍义)
国家:: 槟榔岛马来西亚
疫苗:: jh7x51@gmail.com
网站:: mt4ea.com / liithong.com / MT5EA.COM
短信SMS/WhatsApp:: 60125534397
微信::b0392172
淘宝:: https://shop34551999.world.taobao.com
面子书:: https://www.facebook.com/mt4ea
版权保留 谢绝转载
第12章:整理一下策略003
//+------------------------------------------------------------------+
//| 初级挂单编写.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
#include "子程式BY7X51.mqh"
extern double 盈利目标=45;
double kkkk;
//+------------------------------------------------------------------+
//+----------EA启动执行1次的程序-------------------------------------+
int OnInit()
{
//------防止误用在live户口--------//
if(!IsDemo()){
Alert("不可用在live户口");
ExpertRemove();
return(0);
}
//--- create timer
EventSetTimer(1);//修改成1秒,EA
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//+-------EA退出前最后一口气的程序-----------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//+-------量制EA---------------------------------------------------+
void OnTick()
{
//---
OnTimer();//叫tick 读 timer
}
//+------------------------------------------------------------------+
//+--------时间制EA--------------------------------------------------+
void OnTimer()
{
//---
挂单编写003(); //子程式
}
//+------------------------------------------------------------------+
//+------画面点击效果程式----------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
}
//+------------------------------------------------------------------+
//--------子程式---------------//
void 挂单编写003(){
//---------开始编写---------//
//--------自定义--------------//
货币对=Symbol();
户口检查管理();
//--------自定义--------------//
//-----EA 进场编写1------------//
if(OSS==0&&SELLSTOP线条!=0){SELLSTOP卖下();}
if(OSL==0&&SELLLIMIT线条!=0){SELLLIMIT卖下();}
if(OBS==0&&BUYSTOP线条!=0){BUYSTOP买上();}
if(OBL==0&&BUYLIMIT线条!=0){BUYLIMIT买上();}
//-----出场编写-----------//
//if(AccountProfit()>=盈利目标){关闭全部();} //户口盈利盈利目标就出场
if(s+b==0){kkkk=AccountBalance();}
if(AccountEquity()>=盈利目标+kkkk){关闭全部();}
//---------结束编写---------//
}//end
//--------子程式---------------//