BuySell Indicator For MT5
Table Of Contents:
- BuySell Indicator For MT5
- 安装BuySell Indicator For MT5
- BuySell Indicator For MT5参数
- BuySell Indicator For MT5缓冲区
- 守则主要部分
BuySell Indicator For MT5的BuySell Indicator For MT5
安装BuySell Indicator For MT5
通过上面的表格下载指标后,您需要解压缩zip文件。然后,您需要将文件buysell.mq5复制到MT5安装的文件夹MQL5Indicators中。之后,请重启MT5,然后您将能够在指标列表中看到该指标。
BuySell Indicator For MT5参数
BuySell Indicator For MT5具有要配置的4 参数。
input uint MA_Period=14; input ENUM_MA_METHOD MA_Method=MODE_SMA; // Smoothing method input ENUM_APPLIED_PRICE MA_Price=PRICE_CLOSE; // Price input uint ATR_Period=60;
BuySell Indicator For MT5缓冲区
BuySell Indicator For MT5提供4 缓冲区。
SetIndexBuffer(0,UpBuffer,INDICATOR_DATA); SetIndexBuffer(1,DnBuffer,INDICATOR_DATA); SetIndexBuffer(2,SellBuffer,INDICATOR_DATA); SetIndexBuffer(3,BuyBuffer,INDICATOR_DATA);
守则主要部分
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //---- checking of bars, needed for calculation if(BarsCalculated(MA_Handle) lt rates_total || BarsCalculated(ATR_Handle) lt rates_total || rates_total lt min_rates_total) return(RESET); //---- declaration of local variables int limit,to_copy,bar; double MA[],ATR[]; //---- set starting bar index limit if(prev_calculated gt rates_total || prev_calculated lt =0)// checking of first call limit=rates_total-min_rates_total-2; // starting bar index for all bars else limit=rates_total-prev_calculated; // starting bar index for new bars to_copy=limit+2; //---- copy new data to arrays if(CopyBuffer(MA_Handle,0,0,to_copy,MA) lt =0) return(RESET); if(CopyBuffer(ATR_Handle,0,0,to_copy,ATR) lt =0) return(RESET); //---- set indexing as time series ArraySetAsSeries(MA,true); ArraySetAsSeries(ATR,true); //---- first calculation for(bar=limit; bar gt =0 && !IsStopped(); bar--) { //---- set buffers to zero DnBuffer[bar]=0.0; UpBuffer[bar]=0.0; if(MA[bar] gt MA[bar+1]) DnBuffer[bar]=MA[bar]-ATR[bar]; if(MA[bar] lt MA[bar+1]) UpBuffer[bar]=MA[bar]+ATR[bar]; } //---- recalculation of starting bar index for new bars if(prev_calculated gt rates_total || prev_calculated lt =0)// checking of first call limit--; //---- second calculation for(bar=limit; bar gt =0 && !IsStopped(); bar--) { //---- set buffers to zero BuyBuffer[bar]=0.0; SellBuffer[bar]=0.0; if(UpBuffer[bar+1]&&DnBuffer[bar]) BuyBuffer [bar]=DnBuffer[bar]; if(DnBuffer[bar+1]&&UpBuffer[bar]) SellBuffer[bar]=UpBuffer[bar]; } //---- return(rates_total); } //+------------------------------------------------------------------+