代碼太多了 應該不用那麼複雜
你可以參考一下連接的編法
https://www.mql5.com/zh/code/viewcode/31473/239440/double_ma_cross.mq5
Hung Wen Lin:
代碼太多了 應該不用那麼複雜
你可以參考一下連接的編法
https://www.mql5.com/zh/code/viewcode/31473/239440/double_ma_cross.mq5
你好 我用的是MT4 ,当然也可以实现在主图上画出来,如图1. 但是在附图上就不行。如图2。 另外我编了一个简易的指标,两条均线交叉。源码如下
源码如下:
//+------------------------------------------------------------------+ //| 6indicator.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot da #property indicator_label1 "da" #property indicator_type1 DRAW_HISTOGRAM #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- plot xiao #property indicator_label2 "xiao" #property indicator_type2 DRAW_HISTOGRAM #property indicator_color2 clrGreen #property indicator_style2 STYLE_SOLID #property indicator_width2 2 //--- input parameters input int 大周期=20; input int 小周期=10; //--- indicator buffers double daBuffer[]; double xiaoBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,daBuffer); SetIndexBuffer(1,xiaoBuffer); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { //--- int i,limit; for(i=0;i<600;i++) { daBuffer[i]=iMA(NULL,0,大周期,0,MODE_SMA,PRICE_CLOSE,i); xiaoBuffer[i]=iMA(NULL,0,小周期,0,MODE_SMA,PRICE_CLOSE,i); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
你好
请教一个问题就是我要在附图中画两个柱状图的差值,如下图:
但是我改编程MT4之后,达不到这个效果,重叠部分也画出来了。如下图
请问怎么解决这个问题? 烦请帮忙解答。感谢
下面是源码: