[MT4指标]Trend Manager变色k线指标
主图指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
// Trend Manager.mq4
// Based on indicator sold at traderstradingsystem.com
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
extern int TM_Period = 7;
extern int TM_Shift = 2;
double SpanA_Buffer;
double SpanB_Buffer;
int a_begin;
int init()
{
a_begin=TM_Shift;
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(0,SpanB_Buffer);
SetIndexDrawBegin(0,TM_Period+a_begin-1);
SetIndexLabel(0,"TM_Period+");
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(1,SpanA_Buffer);
SetIndexDrawBegin(1,TM_Period+a_begin-1);
SetIndexLabel(1,"TM_Period");
return(0);
}
int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double high,low,price;
string sColor;
if(Bars<=TM_Period) return(0);
if(counted_bars<1)
{
for(i=1;i<=TM_Period;i++)
{
SpanA_Buffer[Bars-i]=0;
SpanB_Buffer[Bars-i]=0;
}
}
// JUSTIN NOTES
// BASICALLY, I THINK THE FORMULA IS TO GO BACK 7 BARS, SUM THE HIGH LOW, DIVIDE BY 2
// THEN GET THAT SAME VALUE, BUT 2 BARS PREVIOUSLY, IF THE FIRST VALUE IS GREATER IT'S A BUY
// OTHER WISE IT'S A SELL, IF EQUAL, NEAUTRAL
i=Bars-TM_Period;
if(counted_bars>TM_Period) i=Bars-counted_bars-1;
while(i>=0)
{
high=High; low=Low; k=i-1+TM_Period;
while(k>=i)
{
price=High[k];
if(highprice) low=price;
k--;
}
SpanA_Buffer = (high+low)/2.0;
SpanB_Buffer = SpanA_Buffer[i+TM_Shift];
//Print("Span A Buffer[", i, "] = ", (high+low)/2.0);
//Print("Span B Buffer[", i, "] = ", SpanA_Buffer[i+TM_Shift]);
//Print("Span A Price = ", SpanA_Buffer[Bars-TM_Period], " -- Span B Price = ", SpanB_Buffer[Bars-TM_Period]);
if ( SpanA_Buffer > SpanB_Buffer )
{
sColor = "BUY";
}
else if ( SpanA_Buffer < SpanB_Buffer )
{
sColor = "SELL";
}
else
{
sColor = "NEUTRAL";
}
Print(sColor, " -- Bar = ", i, " -- Span A Price (Blue) = ", SpanA_Buffer, " -- Span B Price (Red) = ", SpanB_Buffer);
i--;
}
return(0);
}Icho-Trend%5B1%5D.jpg
发表于:2014-05-18 08:10只看该作者
2楼
:lol
韬客社区www.talkfx.co
发表于:2017-08-11 09:33只看该作者
3楼
阅尽天下指标
韬客社区www.talkfx.co