我想法是在M1周期圖表上 就用M1的最高價-D1周期1號K線的最高價;M1的最低價-D1周期1號K線的最低價
我想法是在M5周期圖表上 就用M5的最低價-D1周期1號K線的最高價;M5的最低價-D1周期1號K線的最低價
。。。。。。。依次類推 畫出類似MACD的柱形圖,
其它能想到的都試了還是不行,結果顯示的是這樣,實在不知道怎么搞了,求大佬們指點指點!!

代碼如下

//------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 8
//#include <MovingAverages.mqh>
#property indicator_type1 DRAW_LINE
#property indicator_type2 DRAW_LINE
#property indicator_type3 DRAW_LINE
#property indicator_type4 DRAW_LINE
#property indicator_type5 DRAW_LINE
#property indicator_color1 clrNONE
#property indicator_color2 clrNONE
#property indicator_color3 clrNONE
#property indicator_color4 clrWhite
#property indicator_color5 clrRed
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 1
//--------------------------------------------------
//--------------------------------------------------
input double ZENGGAO=0.000;
double mac[],mal[],mah[];
int spacebar=1;
double up[],dw[],zj[];
double ma1[],ma2[];
double ma[],uper[],dwer[],mder[];
datetime time0;
string biaoshi="";
string shortname="xiugai1";
//----------------------------------------------------
//-----------------------------------------------------
int OnInit(void)
{
if(IsTesting())
{
ChartSetInteger(0,CHART_SHOW_GRID,false);
ChartSetInteger(0,CHART_MODE,CHART_CANDLES);
}
IndicatorDigits(Digits);
IndicatorShortName(shortname);
SetIndexBuffer(0,mac);
SetIndexBuffer(1,mah);
SetIndexBuffer(2,mal);
SetIndexBuffer(3,up);
SetIndexBuffer(4,dw);
SetIndexLabel(0,"");
SetIndexLabel(1,"");
SetIndexLabel(2,"");
SetIndexLabel(3,"");
SetIndexLabel(4,"");
SetIndexStyle(0,DRAW_NONE,STYLE_SOLID,1,clrNONE);
SetIndexStyle(1,DRAW_NONE,STYLE_SOLID,1,clrNONE);
SetIndexStyle(2,DRAW_NONE,STYLE_SOLID,1,clrNONE);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,2,clrRed);
SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,2,clrLime);
ArraySetAsSeries(mac,true);
ArraySetAsSeries(mah,true);
ArraySetAsSeries(mal,true);
ArraySetAsSeries(up,true);
ArraySetAsSeries(dw,true);
ArrayInitialize(mac,EMPTY_VALUE);
ArrayInitialize(mah,EMPTY_VALUE);
ArrayInitialize(mal,EMPTY_VALUE);
ArrayInitialize(up,EMPTY_VALUE);
ArrayInitialize(dw,EMPTY_VALUE);
return(INIT_SUCCEEDED);
}
//---------------------------------------------------
//------------------------------------------------------
void OnDeinit(const int reason)
{
if(biaoshi!="")
for(int i=ObjectsTotal(0,-1,-1);i>=0;i--)
{
string name=ObjectName(i);
if(StringFind(name,biaoshi,0)>=0)
{
ObjectDelete(0,name);
}
}
if(reason==2)ObjectsDeleteAll(0,-1,-1);
}
//---------------------------------------------------------
//------------------------------------------------------
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 limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit= rates_total-prev_calculated+1;
for(int i=limit-1;i>=0;i--)
{
up[i]=EMPTY_VALUE;
dw[i]=EMPTY_VALUE;
if(i+spacebar>=rates_total) continue;
double diffh=High[i]-iHigh(NULL,PERIOD_D1,i+spacebar);
double diffl=Low[i]-iLow(NULL,PERIOD_D1,i+spacebar);
if(diffh>0) up[i]=diffh+ZENGGAO;
if(diffl<0) dw[i]=diffl-ZENGGAO;
}
return(rates_total);
}
//+------------------------------------------------------------------++
//------------------------------------------------------------------
void OnTimer()
{
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/142109.html
標籤:其他技術專區
