当前位置: 首页 > news >正文

网站模板整站资源网络营销公司好不好

网站模板整站资源,网络营销公司好不好,网站怎样做优化网页,网页排版设计模板MT5编程&#xff0c;有两种方式&#xff0c;一种是函数式编程&#xff0c;一种是面向对象编程。 面向对象编程&#xff0c;会让我们编写代码变得非常简单。 面向对象编程&#xff0c;主要是要熟悉4个类库。 #include <Trade\PositionInfo.mqh> #include <Trade\Tra…

MT5编程,有两种方式,一种是函数式编程,一种是面向对象编程。

面向对象编程,会让我们编写代码变得非常简单。

面向对象编程,主要是要熟悉4个类库。

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\OrderInfo.mqh>

其中 

PositionInfo 是持仓单信息 
OrderInfo    是挂单信息
SymbolInfo  是品种信息
Trade    是交易类库

使用之前,需要定义各种对象的实例

CPositionInfo  m_position;                   // trade position object
CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
COrderInfo     m_order;                      // pending orders object

交易之前,在初始化函数里面,要指定一些相应的属性

//---m_trade.SetExpertMagicNumber(m_magic);  //指定魔术号
//---if(IsFillingTypeAllowed(SYMBOL_FILLING_FOK))m_trade.SetTypeFilling(ORDER_FILLING_FOK);elseif(IsFillingTypeAllowed(SYMBOL_FILLING_IOC))m_trade.SetTypeFilling(ORDER_FILLING_IOC);elsem_trade.SetTypeFilling(ORDER_FILLING_RETURN);
//---m_trade.SetAsyncMode(true);            //指定异步模式,有了这条,可瞬时下单上万单m_trade.SetDeviationInPoints(m_slippage);

下面就不一一介绍了,我给出一个挂单EA的全部源码,可直接下载下去好好学习。

//+------------------------------------------------------------------+
//|                       EA Stop Order(barabashkakvn's edition).mq5 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Хлыстов Владимир"
#property link      "cmillion@narod.ru"
#property version   "2.00"
#property description " Advisor opens a grid of stop orders"
#property description "    When the specified profit level is reached,"
#property description "       it closes all positions and deletes all pending orders"
//---
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\OrderInfo.mqh>
CPositionInfo  m_position;                   // trade position object
CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
COrderInfo     m_order;                      // pending orders object
//--- input parameters
input double   InpProfitClose    = 5;        // Profit purpose (in money)
input bool     InpBuyStop        = true;     // Use Buy stop
input bool     InpSellStop       = true;     // Use Sell stop
input int      InpMaxOrders      = 10;       // Maximum pending orders
input ushort   InpStopLoss       = 0;        // StopLoss ("0" -> off)
input ushort   InpTakeProfit     = 0;        // TakeProfit ("0" -> off)
input ushort   InpDistance       = 100;      // Distance from current price
input double   InpLots           = 0.1;      // Lots
input double   InpLotRatio       = 1.5;      // Lot Ratio
input ulong    m_magic=72994760;             // magic number
//---
ulong          m_slippage=10;                // slippagedouble         ExtStopLoss=0.0;
double         ExtTakeProfit=0.0;
//---
//---
bool           m_bln_close_all=false;        // "true" -> you must close all positions
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit(){if(InpLotRatio<=0.0){string text=__FUNCTION__+", ERROR: "+"The parameter \"Lot Ratio\" can not be less than or equal to zero";Print(text);Alert(text);return(INIT_PARAMETERS_INCORRECT);}
//---if(!m_symbol.Name(Symbol())) // sets symbol namereturn(INIT_FAILED);RefreshRates();string err_text="";if(!CheckVolumeValue(InpLots,err_text)){Print(__FUNCTION__,", ERROR: ",err_text);return(INIT_PARAMETERS_INCORRECT);}
//---m_trade.SetExpertMagicNumber(m_magic);
//---if(IsFillingTypeAllowed(SYMBOL_FILLING_FOK))m_trade.SetTypeFilling(ORDER_FILLING_FOK);elseif(IsFillingTypeAllowed(SYMBOL_FILLING_IOC))m_trade.SetTypeFilling(ORDER_FILLING_IOC);elsem_trade.SetTypeFilling(ORDER_FILLING_RETURN);
//---m_trade.SetAsyncMode(true);m_trade.SetDeviationInPoints(m_slippage);
//---ExtStopLoss=InpStopLoss*m_symbol.Point();ExtTakeProfit=InpTakeProfit*m_symbol.Point();
//---m_bln_close_all=false;                    // "true" -> you must close all positions
//---return(INIT_SUCCEEDED);}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason){
//---}double Ask,Bid;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int RefreshRates0(string symbol=""){if(symbol=="")symbol=_Symbol;MqlTick last_tick;SymbolInfoTick(symbol,last_tick);double Bid0=last_tick.bid;SymbolInfoTick(_Symbol,last_tick);Bid=last_tick.bid;Ask=last_tick.ask;if(Bid0==0)Print("刷新数据失败,请检查MT5是不是掉线了,或者打开对应图表加速数据图表更新 "+symbol);if((Bid0)==0)return(0);elsereturn(1);}input bool 启用新增功能=1;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void funx(){if(启用新增功能==false)return;if(A_Mq4_FirstOpen_Price(0)>0)if(Bid>A_Mq4_FirstOpen_Price(0))if(Countlots(1)>Countlots(0))m_trade.Buy(Countlots(1)-Countlots(0), m_symbol.Name(), Ask, 0.0, 0.0,  "_sc");if(Bid<A_Mq4_FirstOpen_Price(1))if(Countlots(1)<Countlots(0))m_trade.Sell(Countlots(0)-Countlots(1), m_symbol.Name(), Bid, 0.0, 0.0,  "_sc");}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick(){RefreshRates0();funx();if(m_bln_close_all){CloseAllPositions();DeleteAllOrders();if(CalculateAllPositions()==0.0 && CalculateAllPendingOrders()==0.0)m_bln_close_all=false;}
//---double Profit=0.0;for(int i=PositionsTotal()-1;i>=0;i--)if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)Profit+=m_position.Commission()+m_position.Swap()+m_position.Profit();
//---if(Profit>=InpProfitClose) // close all{m_bln_close_all=true;return;}
//---if(CalculateAllPendingOrders()!=0){MoveOrder();return;}
//---if(!RefreshRates())return;int StopsLevel=m_symbol.StopsLevel();if(StopsLevel==0)StopsLevel=m_symbol.Spread()*3;for(int i=1; i<=InpMaxOrders; i++){if(InpDistance*i>StopsLevel){double Lot=(i==1)?InpLots:LotCheck(InpLots*(double)(i-1)*InpLotRatio);if(Lot!=0.0){if(InpBuyStop){double Price=m_symbol.NormalizePrice(m_symbol.Ask()+(double)InpDistance*(double)i*m_symbol.Point());double sl=(InpStopLoss==0)?0.0:m_symbol.NormalizePrice(Price-ExtStopLoss);double tp=(InpTakeProfit==0)?0.0:m_symbol.NormalizePrice(Price+ExtTakeProfit);m_trade.BuyStop(Lot,Price,m_symbol.Name(),sl,tp);}if(InpSellStop){double Price=m_symbol.NormalizePrice(m_symbol.Bid()-(double)InpDistance*(double)i*m_symbol.Point());double sl=(InpStopLoss==0)?0.0:m_symbol.NormalizePrice(Price+ExtStopLoss);double tp=(InpTakeProfit==0)?0.0:m_symbol.NormalizePrice(Price-ExtTakeProfit);m_trade.SellStop(Lot,Price,m_symbol.Name(),sl,tp);}}}}
//---}
//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,const MqlTradeRequest &request,const MqlTradeResult &result){
//---}
//+------------------------------------------------------------------+
//| Refreshes the symbol quotes data                                 |
//+------------------------------------------------------------------+
bool RefreshRates(void){
//--- refresh ratesif(!m_symbol.RefreshRates()){Print("RefreshRates error");return(false);}
//--- protection against the return value of "zero"if(m_symbol.Ask()==0 || m_symbol.Bid()==0)return(false);
//---return(true);}
//+------------------------------------------------------------------+
//| Check the correctness of the order volume                        |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume,string &error_description){
//--- minimal allowed volume for trade operationsdouble min_volume=m_symbol.LotsMin();if(volume<min_volume){error_description=StringFormat("Volume is less than the minimal allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);return(false);}
//--- maximal allowed volume of trade operationsdouble max_volume=m_symbol.LotsMax();if(volume>max_volume){error_description=StringFormat("Volume is greater than the maximal allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);return(false);}
//--- get minimal step of volume changingdouble volume_step=m_symbol.LotsStep();int ratio=(int)MathRound(volume/volume_step);if(MathAbs(ratio*volume_step-volume)>0.1){error_description=StringFormat("Volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f",volume_step,ratio*volume_step);return(false);}error_description="Correct volume value";return(true);}
//+------------------------------------------------------------------+
//| Checks if the specified filling mode is allowed                  |
//+------------------------------------------------------------------+
bool IsFillingTypeAllowed(int fill_type){
//--- Obtain the value of the property that describes allowed filling modesint filling=m_symbol.TradeFillFlags();
//--- Return true, if mode fill_type is allowedreturn((filling & fill_type)==fill_type);}
//+------------------------------------------------------------------+
//| Lot Check                                                        |
//+------------------------------------------------------------------+
double LotCheck(double lots){
//--- calculate maximum volumedouble volume=NormalizeDouble(lots,2);double stepvol=m_symbol.LotsStep();if(stepvol>0.0)volume=stepvol*MathFloor(volume/stepvol);
//---double minvol=m_symbol.LotsMin();if(volume<minvol)volume=minvol;
//---double maxvol=m_symbol.LotsMax();if(volume>maxvol)volume=maxvol;return(volume);}
//+------------------------------------------------------------------+
//| Close all positions                                              |
//+------------------------------------------------------------------+
void CloseAllPositions(){for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of current positionsif(m_position.SelectByIndex(i))     // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol}
//+------------------------------------------------------------------+
//| Calculate all positions                                          |
//+------------------------------------------------------------------+
int CalculateAllPositions(){int total=0;for(int i=PositionsTotal()-1;i>=0;i--)if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)total++;
//---return(total);}//+------------------------------------------------------------------+
int CountT(ENUM_POSITION_TYPE i0){int total=0;for(int i=PositionsTotal()-1;i>=0;i--)if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)if(m_position.PositionType()==i0)total++;
//---return(total);}//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Countlots(ENUM_POSITION_TYPE i0){double total=0;for(int i=PositionsTotal()-1;i>=0;i--)if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)if(m_position.PositionType()==i0)total=total+m_position.Volume();
//---return(total);}//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double  A_Mq4_FirstOpen_Price(ENUM_POSITION_TYPE Type){double A_Mq4_FirstOpen_Price=0;for(int i=0; i<PositionsTotal(); i++)// for(int i=PositionsTotal()-1;i>=0;i--)if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)if(m_position.PositionType()==Type){A_Mq4_FirstOpen_Price=m_position.PriceOpen();break;}return(A_Mq4_FirstOpen_Price);}
//+------------------------------------------------------------------+
//| Calculate all pending orders for symbol                          |
//+------------------------------------------------------------------+
int CalculateAllPendingOrders(){int total=0;for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current ordersif(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its propertiesif(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic)total++;
//---return(total);}
//+------------------------------------------------------------------+
//| Delete all pending orders                                                    |
//+------------------------------------------------------------------+
void DeleteAllOrders(){for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current ordersif(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its propertiesif(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic)m_trade.OrderDelete(m_order.Ticket());}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void MoveOrder(){int StopsLevel=m_symbol.StopsLevel();if(StopsLevel==0)StopsLevel=m_symbol.Spread()*3;int b=0;int s=0;for(int i=0;i<OrdersTotal();i++) // returns the number of current ordersif(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its propertiesif(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic){if(m_order.OrderType()==ORDER_TYPE_BUY_STOP){RefreshRates();b++;double zone=(StopsLevel+(b-1)*InpDistance)*m_symbol.Point();double newPriceOpen=m_symbol.NormalizePrice(m_symbol.Ask()+zone);if(m_order.PriceOpen()>newPriceOpen){Print("BUY:",m_order.Ticket(),",",m_order.PriceOpen(),"->",newPriceOpen,"->",m_symbol.Ask());if(NormalizeDouble(newPriceOpen-m_order.PriceOpen(),8)!=0){m_trade.OrderModify(m_order.Ticket(),newPriceOpen,m_order.StopLoss(),m_order.TakeProfit(),ORDER_TIME_GTC,0);}}}if(m_order.OrderType()==ORDER_TYPE_SELL_STOP){RefreshRates();s++;double zone=(StopsLevel+(s-1)*InpDistance)*m_symbol.Point();double newPriceOpen=m_symbol.NormalizePrice(m_symbol.Bid()-zone);if(m_order.PriceOpen()<newPriceOpen){Print("SELL:",m_order.Ticket(),",",m_order.PriceOpen(),"->",newPriceOpen,"->",m_symbol.Bid());if(NormalizeDouble(newPriceOpen-m_order.PriceOpen(),8)!=0){m_trade.OrderModify(m_order.Ticket(),newPriceOpen,m_order.StopLoss(),m_order.TakeProfit(),ORDER_TIME_GTC,0);}}}}}
//+------------------------------------------------------------------+

http://www.khdw.cn/news/34300.html

相关文章:

  • 怎样把自己的网站上传百度官网下载
  • 只做动漫的h网站百度客服在线咨询人工服务
  • app下载登录郑州seo顾问外包公司
  • 馆陶做网站以图搜图百度识图网页版
  • 做ug图纸的网站百度竞价托管公司
  • 重庆九龙坡区哪里有做网站的域名注册时间查询
  • 阿里云做网站流程活动推广
  • 开发网站商城营销型网站建设服务
  • 网站站点文件夹权限设置seo什么意思中文意思
  • 郑州的网站建设一个新产品策划方案
  • 深圳品牌公寓有哪些建站优化公司
  • 博客做网站淘宝关键词推广
  • dz 做企业网站上海seo有哪些公司
  • 描述网站开发的流程关键词优化公司如何选择
  • 成都公司做网站多少钱外贸营销渠道
  • 连云港集团网站建设google搜索关键词
  • 国外做饮料视频网站百度信息流平台
  • 消防做设计有什么网站怎么创建一个网页
  • 视频网站如何做微信营销整合营销传播成功案例
  • 网站怎么做qq的授权登陆seo成创网络
  • 手机网站图片做多大西安seo诊断
  • 内部网站建设网站推广排名优化
  • 做网站的 深圳北京网站优化推广公司
  • 东阳app开发宁波正规站内优化seo
  • 网站群建设分析seo网络优化招聘信息
  • wordpress自定义页面模板下载网站seo搜索
  • 给艺术家做网站的工作百度竞价推广怎么样才有效果
  • 门户型网站网站内容检测
  • 网站建设 开发杭州小周seo
  • seo网站的锚文本怎么写百度公司简介