图片
周末有位一又友问起Heikiun Ashi决策,那时在外地没如何讲演,今天在这里与全球系数共享文采版与MT4版源码的不同,有有趣有趣学编写决策的一又友系数来探讨下。
Heikiun Ashi决策Heikiun Ashi决策称平均棒图或平滑烛炬图,通过设想每个时候周期的开盘价、最高价、最廉价和收盘价,生成新的烛炬图,以更明晰地展现价钱趋势。这种决策有助于过滤市集杂音,突显主要趋势,提议用于大周期看趋势。Heikiun Ashi决策并不提议单独行为期货、外汇粗略黄金的来去决策的依据,投资者应当与其他时刻分析决策、基本面分析和市集热枕等要素相议论,进行概括判断。图片
图片
源 码 下方共享的Heikiun Ashi决策源码为主图K线样子,是阐述常见的样貌改写。仅行为战略念念路拓展,不提议径直用于期货等投资实盘中(投资有风险,入市须严慎)。来去员不错阐述艾云战略所提供的决策源码,议论闲居的来去告诫进行改编,酿成我方的来去战略。文采版:适用于文采6、7、8等软件
M:=3;XXOPEN:=(REF(OPEN,M)+REF(CLOSE,M))/2;XXCLOSE:=(HIGH+LOW+CLOSE+OPEN)/4;XXHIGH:=MAX1(XXOPEN,XXCLOSE,HHV(HIGH,M));XXLOW:=MIN1 (XXOPEN,XXCLOSE,LLV(LOW,M));STICKLINE(XXCLOSE>XXOPEN,XXCLOSE ,XXOPEN ,8,1 ),COLORRED;DRAWLINE(XXCLOSE>XXOPEN,XXHIGH ,XXCLOSE>XXOPEN,XXCLOSE,COLORRED );DRAWLINE(XXCLOSE>XXOPEN,XXOPEN ,XXCLOSE>XXOPEN,XXLOW ,COLORRED);STICKLINE(XXCLOSE<=XXOPEN,XXCLOSE ,XXOPEN ,8,0 ),COLORFFFF66;DRAWLINE(XXCLOSE<=XXOPEN,XXOPEN ,XXCLOSE<=XXOPEN,XXHIGH,COLORFFFF66);DRAWLINE(XXCLOSE<=XXOPEN,XXCLOSE ,XXCLOSE<=XXOPEN,XXLOW,COLORFFFF66);MT4版:
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3
//---
input color ExtColor1 = Red; // Shadow of bear candlestick
input color ExtColor2 = White; // Shadow of bull candlestick
input color ExtColor3 = Red; // Bear candlestick body
input color ExtColor4 = White; // Bull candlestick body
//--- buffers
double ExtLowHighBuffer[];
double ExtHighLowBuffer[];
double ExtOpenBuffer[];
double ExtCloseBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
void OnInit(void)
{
IndicatorShortName("Heiken Ashi");
IndicatorDigits(Digits);
//--- indicator lines
SetIndexStyle(0,DRAW_HISTOGRAM,0,1,ExtColor1);
SetIndexBuffer(0,ExtLowHighBuffer);
SetIndexStyle(1,DRAW_HISTOGRAM,0,1,ExtColor2);
SetIndexBuffer(1,ExtHighLowBuffer);
SetIndexStyle(2,DRAW_HISTOGRAM,0,3,ExtColor3);
SetIndexBuffer(2,ExtOpenBuffer);
SetIndexStyle(3,DRAW_HISTOGRAM,0,3,ExtColor4);
SetIndexBuffer(3,ExtCloseBuffer);
//---
SetIndexLabel(0,"Low/High");
SetIndexLabel(1,"High/Low");
SetIndexLabel(2,"Open");
SetIndexLabel(3,"Close");
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
SetIndexDrawBegin(2,10);
SetIndexDrawBegin(3,10);
//--- indicator buffers mapping
SetIndexBuffer(0,ExtLowHighBuffer);
SetIndexBuffer(1,ExtHighLowBuffer);
SetIndexBuffer(2,ExtOpenBuffer);
SetIndexBuffer(3,ExtCloseBuffer);
//--- initialization done
}
//+------------------------------------------------------------------+
//| Heiken Ashi |
//+------------------------------------------------------------------+
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,pos;
double haOpen,haHigh,haLow,haClose;
//---
if(rates_total<=10)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtLowHighBuffer,false);
ArraySetAsSeries(ExtHighLowBuffer,false);
ArraySetAsSeries(ExtOpenBuffer,false);
ArraySetAsSeries(ExtCloseBuffer,false);
ArraySetAsSeries(open,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- preliminary calculation
if(prev_calculated>1)
pos=prev_calculated-1;
else
{
//--- set first candle
if(open[0]<close[0])
{
ExtLowHighBuffer[0]=low[0];
ExtHighLowBuffer[0]=high[0];
}
else
{
ExtLowHighBuffer[0]=high[0];
ExtHighLowBuffer[0]=low[0];
}
ExtOpenBuffer[0]=open[0];
ExtCloseBuffer[0]=close[0];
//---
pos=1;
}
//--- main loop of calculations
for(i=pos; i<rates_total; i++)
{
haOpen=(ExtOpenBuffer[i-1]+ExtCloseBuffer[i-1])/2;
haClose=(open[i]+high[i]+low[i]+close[i])/4;
haHigh=MathMax(high[i],MathMax(haOpen,haClose));
haLow=MathMin(low[i],MathMin(haOpen,haClose));
if(haOpen<haClose)
{
ExtLowHighBuffer[i]=haLow;
ExtHighLowBuffer[i]=haHigh;
}
else
{
ExtLowHighBuffer[i]=haHigh;
ExtHighLowBuffer[i]=haLow;
}
ExtOpenBuffer[i]=haOpen;
ExtCloseBuffer[i]=haClose;
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
艾云战略网站kaiyun.com
https://www.aiycl.cn温馨指示:投资有风险,入场需严慎! 本站仅提供存储办事,扫数推行均由用户发布,如发现存害或侵权推行,请点击举报。XINWENDONGTAI
品种 最高价 最廉价 巨额价 大白菜 2.60 2.00 2.20 生菜 6.20 3.40 4.60 香菜 9.40 7.80 8.20 韭菜 5.80 4.80 5.20 洋白菜 2.60 1.60 2.20 小葱 8.20 7.20 7.60 胡萝卜 4.00 3.00 3.60 土豆 4.00 3.00 3.60 芋头 10.80 8.80 9.60 葱头 3.20 2.60 3.00 生姜 10.00 8.00 9.00 大蒜 24.60 13.40 19.60 芹菜 5.80 4.
品种 最高价 最廉价 巨额价 大白菜 2.20 1.40 1.80 油菜 5.00 4.20 4.60 生菜 5.80 4.60 5.20 菠菜 7.40 6.20 6.80 韭菜 4.00 3.40 3.70 洋白菜 6.00 4.80 5.40 胡萝卜 5.40 4.00 4.70 土豆 5.00 4.00 4.40 葱头 15.00 12.00 13.50 大葱 10.00 8.20 9.10 生姜 16.20 12.60 14.40 大蒜 5.00 4.00 4.50 芹菜 5.20
品种 最高价 最廉价 大批价 大白菜 -- -- 2.00 油菜 -- -- 2.60 生菜 -- -- 3.20 菠菜 -- -- 12.00 空腹菜 -- -- 5.66 韭菜 -- -- 4.34 小葱 -- -- 4.66 胡萝卜 -- -- 2.96 土豆 -- -- 2.40 大葱 -- -- 3.34 生姜 -- -- 6.60 大蒜 -- -- 10.34 蒜薹 -- -- 8.00 白萝卜 -- -- 1.66 菜花 -- -- 5.94 西兰花 -- -- 6.06 西红柿
品种 最高价 最廉价 巨额价 大白菜 1.20 0.90 1.00 甘蓝 0.80 0.50 0.70 油菜 2.20 1.20 1.80 小白菜 1.60 0.80 1.40 生菜 1.00 0.40 0.60 菠菜 6.00 4.40 5.40 茼蒿 6.20 5.00 6.00 香菜 8.00 5.00 6.60 油麦菜 1.60 1.20 1.40 空腹菜 4.00 3.00 3.60 韭菜 2.40 1.20 1.60 蒜苗 2.00 1.00 1.40 茴香 1.60 0.60 1
品种 最高价 最廉价 巨额价 大白菜 1.20 1.00 1.10 油菜 2.60 2.20 2.40 生菜 2.40 2.00 2.20 韭菜 5.80 5.20 5.40 洋白菜 1.20 1.00 1.10 胡萝卜 3.20 2.80 3.00 土豆 2.30 1.60 2.00 大葱 3.40 3.00 3.20 生姜 7.20 6.60 6.80 大蒜 7.20 6.60 6.80 芹菜 2.60 2.20 2.40 莴笋 2.80 2.40 2.60 莲藕 7.00 6.40 6.