admin 发表于 2018-1-18 15:23:38

demarker indicator



//+------------------------------------------------------------------+
//|                                                   DeMarker.mq4 |
//|                      Copyright ?2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_level1 0.3
#property indicator_level2 0.7
//---- input parameters
extern int DeMarkerPeriod=14;
//---- buffers
double DeMarkerBuffer[];
double ExtMaxBuffer[];
double ExtMinBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(0,DeMarkerBuffer);
   SetIndexBuffer(1,ExtMaxBuffer);
   SetIndexBuffer(2,ExtMinBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
   short_name="DeM("+DeMarkerPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//---- first values aren't drawn
   SetIndexDrawBegin(0,DeMarkerPeriod);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| DeMarker                                                         |
//+------------------------------------------------------------------+
int start()
{
   double dNum;
   int    i,nCountedBars;
//---- insufficient data
   if(Bars<=DeMarkerPeriod) return(0);
//---- bars count that does not changed after last indicator launch.
   nCountedBars=IndicatorCounted();
//----
   ExtMaxBuffer=0.0;
   ExtMinBuffer=0.0;
   if(nCountedBars>2) i=Bars-nCountedBars-1;
   else               i=Bars-2;
   while(i>=0)
   {
      dNum=High-High;
      if(dNum<0.0) dNum=0.0;
      ExtMaxBuffer=dNum;
      
      dNum=Low-Low;
      if(dNum<0.0) dNum=0.0;
      ExtMinBuffer=dNum;

      i--;
   }   
//---- initial zero
   if(nCountedBars<1)
      for(i=1; i<=DeMarkerPeriod; i++)
         DeMarkerBuffer=0.0;   
//----
   i=Bars-DeMarkerPeriod-1;
   if(nCountedBars>=DeMarkerPeriod) i=Bars-nCountedBars-1;
   while(i>=0)
   {
      dNum=iMAOnArray(ExtMaxBuffer,0,DeMarkerPeriod,0,MODE_SMA,i)+
         iMAOnArray(ExtMinBuffer,0,DeMarkerPeriod,0,MODE_SMA,i);
      if(dNum!=0.0)
         DeMarkerBuffer=iMAOnArray(ExtMaxBuffer,0,DeMarkerPeriod,0,MODE_SMA,i)/dNum;
      else
         DeMarkerBuffer=0.0;
      
      i--;
   }
   return(0);
}
//+------------------------------------------------------------------+




雨轩 发表于 2020-3-5 21:53:28

我是来刷分的,嘿嘿

一抹邪阳 发表于 2020-6-9 10:59:03

:lol不错

1毛硬币 发表于 2020-7-6 10:00:29

谢谢楼主分享

你的笑容 发表于 2020-7-17 16:05:35

学习了,不错

xing520 发表于 2020-8-19 17:49:22

学习了,不错

christmas 发表于 2020-8-24 10:42:10

学习了,不错

honk0445 发表于 2020-9-6 16:00:01

学习了,不错

dslapu 发表于 2020-11-20 14:32:39

顶下

你哈的粉丝 发表于 2020-11-25 15:13:42

{:1_186:}
页: [1] 2
查看完整版本: demarker indicator