诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

BT1.mq4

BT1指标用不同颜色的线段标识不同趋势的K线,行情转折点的时候也有点像分型指标。

图表:BT1指标

源码:

//+-----------------------------------------------------------------------+
//|                                                               BT1.mq4 |
//|                                    Copyright @2005. Alejandro Galindo |
//+-----------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com/"
   
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

extern int RISK=3;
extern int CountBars=500;

double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1);
   SetIndexBuffer(0,Buffer1);
   SetIndexBuffer(1,Buffer2);
   Comment("www.125808047.com");
  }
//+------------------------------------------------------------------+
//| ASCTrend1                                                  |
//+------------------------------------------------------------------+
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[])
  {
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+11+1);
   SetIndexDrawBegin(1,Bars-CountBars+11+1);
   int i,shift,counted_bars=IndicatorCounted();
   int Counter,value10,value11;
   double x1,x2;
   double value2;
   double TrueCount,Range,AvgRange,MRO1,MRO2;
   
   value10=3+RISK*2;
   x1=67+RISK;
   x2=33-RISK;
   value11=value10;

   if(Bars<=value11+1) return(0);

   if(counted_bars<value11+1)
   {
      for(i=1;i<=0;i++) Buffer1[CountBars-i]=0.0;
      for(i=1;i<=0;i++) Buffer2[CountBars-i]=0.0;
   }

   shift=CountBars-11-1;
   while(shift>=0)
     {
     
   Counter=shift;
	Range=0.0;
	AvgRange=0.0;
	for (Counter=shift; Counter<=shift+9; Counter++) AvgRange=AvgRange+MathAbs(High[Counter]-Low[Counter]);
		
	Range=AvgRange/10;
	Counter=shift;
	TrueCount=0;
	while (Counter<shift+9 && TrueCount<1)
		{if (MathAbs(Open[Counter]-Close[Counter+1])>=Range*2.0) TrueCount=TrueCount+1;
		Counter=Counter+1;
		}
	if (TrueCount>=1) {MRO1=Counter;} else {MRO1=-1;}
	Counter=shift;
	TrueCount=0;
	while (Counter<shift+6 && TrueCount<1)
		{if (MathAbs(Close[Counter+3]-Close[Counter])>=Range*4.6) TrueCount=TrueCount+1;
		Counter=Counter+1;
		}
	if (TrueCount>=1) {MRO2=Counter;} else {MRO2=-1;}
	if (MRO1>-1) {value11=3;} else {value11=value10;}
	if (MRO2>-1) {value11=4;} else {value11=value10;}
	value2=100-MathAbs(iWPR(NULL,0,value11,shift)); // PercentR(value11=9)
   Buffer1[shift]=0;
	Buffer2[shift]=0;
	if (value2>x1)
		{
		Buffer1[shift]=Low[shift]; Buffer2[shift]=High[shift];
		}
	if (value2<x2)
		{
		Buffer1[shift]=High[shift]; Buffer2[shift]=Low[shift];
		}
      shift--;
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » BT1.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏