K Trade Lib Pro 5
- Bibliotecas
- Kaijun Wang
- Versão: 2.0
- Ativações: 5
MT4/5通用交易库( 一份代码通用4和5 )
#ifdef __MQL5__ #define KOD_TICKET ulong #define KOD_MAGIC long #else #define KOD_TICKET long #define KOD_MAGIC int #endif class ODLIST; #import "K Trade Lib Pro 5.ex5" //祝有个美好开始,运行首行加入 void StartGood() ; //简单开单 long OrderOpen(int type,double volume,int magic,string symbol="",string comment="",double opprice=0,double sl=0,double tp=0,int expiration=0,bool slsetmode=false,bool tpsetmode=false); //复杂开单 void SetMagic(int magic,int magic_plus=0); void SetLotsAddMode(int mode=0,double lotsadd=0); long OrderOpenAdvance(int mode,int type,double volume,int step,int magic,string symbol="",string comment="",double sl=0,double tp=0,bool slsetmode=false,bool tpsetmode=false); //平仓函数 bool K_OrderClose(int type,KOD_MAGIC magic,string symbol="",int is_profit=0,double profit_value=0,bool ispoint=false ); //订单详细获取. int OrderTotal(int type=0,KOD_MAGIC magic=-1,string symbol=""); ODLIST* OrderLowPrice(int type=0,KOD_MAGIC magic=-1,string symbol=""); ODLIST* OrderHighPrice(int type=0,KOD_MAGIC magic=-1,string symbol=""); ODLIST* OrderLowTime(int type=0,KOD_MAGIC magic=-1,string symbol="") ; ODLIST* OrderHighTime(int type=0,KOD_MAGIC magic=-1,string symbol="") ; #import class ODLIST{ //order information private: //datetime ctrl_time; ODLIST m_list[]; ODLIST* m_parent; public: int m_total; int m_total_vir; ODLIST* m_sort_price[]; ODLIST* m_sort_time[]; KOD_TICKET ticket; int type; long op_time; long close_time; double lots; double op_price; double close_price; double sl; double tp; string symbol; double profit; double commission; //获取总手续费 MT5无效 double swap; long expiration; KOD_MAGIC magic; string comment; long flag1; long flag2; string m_memo; };
2.复杂订单系统开单(包含逆势加仓,顺势加仓,随机间距加仓; 手数增加模式有倍数模式,增量模式,以及固定手数模式)
void SetMagic( int magic, //设置MAGIC,本设置是针对需要统计订单所对应的魔术号 int magic_plus=0 //可以设置范围 当 (魔术号>=magic ,魔术号<=magic+magic_plus) 的范围内的魔术号订单都会作为统计 );
void SetLotsAddMode( int mode=0, //1->倍数开仓 2->增量开仓 ,0或者其他->固定手数下面参数设置无效 double lotsadd=0 //根据mode设置而定,倍率手数本参数为倍率,增量模式为增量,否则无效 );
long OrderOpenAdvance( int mode, //0x1 逆势加仓,0x2顺势加仓,0x4间距随机加仓 int type, //交易类型 0->BUY 1->SELL double volume, //固定手数 int step, //加仓间距 int magic, //魔术号 string symbol="", //品种 string comment="",//注释 double sl=0, //止损设置(默认设置点数) double tp=0, //止盈设置(默认设置点数) bool slsetmode=false,//false为sl点数设置,true为sl价格模式 bool tpsetmode=false //false为tp点数设置,true为tp价格模式 );
交易范例:(马丁逆势加仓) 非常简单实现马丁加仓,同样可以简单的实现顺势加仓等
void OnTick() { //--- SetLotsAddMode(1,2.0); int mode=1;//逆势加仓模式 int type=0;//0为多单,1为空单 同系统方式 double lots=0.01; //手数设置 int step=200; //加仓间距 int magic =556024;//设置魔术号 OrderOpenAdvance(mode,type,lots,step,magic); }