请教一个问题,一个柱状图需要两个buff,如果分别定义了不同的颜色,那么他会以哪个颜色显示?愁了一天了

 

已知:

假如我们在0号K线上划一个柱图。需要定义两个buff,一个A 一个B并且同时在A【0】

b[0]上定义价格高点,价格低点。SetIndexStyle 函数设置 DRAW_HISTOGRAM 才能在这个0线上划出这个柱线。

问题:

两个buff同时定义了颜色: clrYellow、 clrRed。那么这两个buff画出的一根K线,要采用哪个buff的颜色值呢?

下列代码IMA柱线,自动分了颜色。但是我自己写的固定值代码(注释段)统一值,是统一的黄色,这个变色的原理是什么?我很纳闷。



 #property copyright "Ali Mojtabaei."
#property link "https://telegram.me/mqlbyAliMojtabaei"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
double A [], B [];
int i, limit;
// + ----------------------------------------------- ------------------- +
// | Custom indicator initialization function |
// + ----------------------------------------------- ------------------- +
int OnInit ()
{
SetIndexBuffer (0, A);
SetIndexBuffer (1, B);
SetIndexStyle (0, DRAW_HISTOGRAM, STYLE_SOLID, 1, clrYellow);
SetIndexStyle (1, DRAW_HISTOGRAM, STYLE_SOLID, 1, clrRed);
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 [])
{

/ * for (i = 0; i <= 90; i ++) {

B [i] = 1.1024;
A [i] = 1.1097;
} * /

for (i = 0; i <= 90; i ++)
{
A [i] = iMA (Symbol (), PERIOD_CURRENT, 10,0, MODE_SMMA, PRICE_TYPICAL, i);
B [i] = iMA (Symbol (), PERIOD_CURRENT, 100,0, MODE_SMMA, PRICE_TYPICAL, i);
}

return (rates_total);
} 
MQL TRAINING
MQL TRAINING
  • telegram.me
آموزش برنامه نویسی زبان MQL اکسپرت نویسی اندیکاتور نویسی در این کانال مباحث اکسپرت و اندیکاتور نویسی بصورت قدم به قدم و همراه با مثالهای متعدد آموزش داده میشود.
 
xtgrrk:

已知:

假如我们在0号K线上划一个柱图。需要定义两个buff,一个A 一个B并且同时在A【0】

b[0]上定义价格高点,价格低点。SetIndexStyle 函数设置 DRAW_HISTOGRAM 才能在这个0线上划出这个柱线。

问题:

两个buff同时定义了颜色: clrYellow、 clrRed。那么这两个buff画出的一根K线,要采用哪个buff的颜色值呢?

下列代码IMA柱线,自动分了颜色。但是我自己写的固定值代码(注释段)统一值,是统一的黄色,这个变色的原理是什么?我很纳闷。



MT4上面基本是通过写两个指标,然后把不符合条件的暂时丢掉,这样就能实现多个颜色的效果

原因: