Thread: Smoothed Demark
View Single Post
  #3 (permalink)  
Old 02-18-2006, 07:57 AM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 20,070
Blog Entries: 241
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by 006
Worst case, can someone provide the mt4 demark code so i can work on it?

muchos gracias
It is here:

Code:
//+------------------------------------------------------------------+
//|                                                     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 DeMaxBuffer[];
double DeMinBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(0, DeMarkerBuffer);
   SetIndexBuffer(1, DeMaxBuffer);
   SetIndexBuffer(2, DeMinBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,DeMarkerBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="DeM("+DeMarkerPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,DeMarkerPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DeMarkerM                                                         |
//+------------------------------------------------------------------+
int start()
  {
   DeMaxBuffer[Bars-1] = 0.0;
   DeMinBuffer[Bars-1] = 0.0;
   int i=Bars-2;
   while(i>=0)
     {
      if(High[i] > High[i+1])
        DeMaxBuffer[i] = High[i] - High[i+1];
      else
        DeMaxBuffer[i] = 0.0; 
      if(Low[i] < Low[i+1])
        DeMinBuffer[i] = Low[i+1] - Low[i];
      else
        DeMinBuffer[i] = 0.0; 
      i--;
     }   
   int counted_bars=IndicatorCounted();
//---- 
   if(Bars<=DeMarkerPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=DeMarkerPeriod;i++) DeMarkerBuffer[Bars-i]=0.0;   
//----
   i=Bars-DeMarkerPeriod-1;
   if(counted_bars>=DeMarkerPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      double SumiMAOnArray = iMAOnArray(DeMaxBuffer, 0, DeMarkerPeriod, 0, MODE_SMA, i) + iMAOnArray(DeMinBuffer, 0, DeMarkerPeriod, 0, MODE_SMA, i);
      if(!bCompareDouble(SumiMAOnArray,0.0))
         DeMarkerBuffer[i] = iMAOnArray(DeMaxBuffer, 0, DeMarkerPeriod, 0, MODE_SMA, i)/ SumiMAOnArray;
      else
         DeMarkerBuffer[i] = 0.0;
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
 bool bCompareDouble (double dNumber1, double dNumber2)
    {
     bool bCompare=NormalizeDouble(dNumber1 - dNumber2,8) == 0;
     return(bCompare);
    }
Reply With Quote