View Single Post
  #10 (permalink)  
Old 02-22-2006, 08:08 PM
ycomp's Avatar
ycomp ycomp is offline
Member
 
Join Date: Jan 2006
Posts: 93
ycomp is on a distinguished road
small bug in MTF_DeMarker

code I posted works but DeMarker is displayed as a period of 13 only. Here is the fixed copy that actually uses the DeMarkerPeriod variable.

can't seem to upload a file anymore though... it just says page not found.. therefore here are the instructions to change it:

just open in notepad and paste this text below and save it as "MTF_DeMarker_v1.mq4"

Code:
//---------------------------------------------------------------
//PARAMS:
//- TimeFramePeriod: # of minutes in TF. 
//  NOTE: I did not test non-standard TFs or a TimeFramePeriod
//        value less than that of current chart. So they probably
//        won't work.
// - DeMarkerPeriod: self explanatory
//---------------------------------------------------------------

#property copyright "Copyright © 2006 ycomp"
#property link      "ycomp"

#define MIN_BARS_REQUIRED 200 // Just a safe amount here. Probably needs much less.


//--- Indicator Settings
#property indicator_separate_window

#property indicator_level1 0.3
#property indicator_level2 0.7

#property indicator_buffers 1

#property indicator_color1 DodgerBlue
#property indicator_width1 2

#property indicator_maximum 1
#property indicator_minimum 0

//---- input parameters

extern int TimeFramePeriod;

extern int DeMarkerPeriod = 14;

//---- buffers
double buff[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  if (Bars < MIN_BARS_REQUIRED) return (-1);

  IndicatorDigits(Digits);
    
  SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
  SetIndexBuffer(0, buff);  
  
  string paramDesc =
    "(" +
      getPeriodDesc(TimeFramePeriod) + ", " +
      DeMarkerPeriod +
    ")";
                      
  IndicatorShortName("MTF_DeMarker" + paramDesc);

  // Set Index Labels
  SetIndexLabel(0, "MTF_DeM" + paramDesc);   

  return(0);
 }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }

string getPeriodDesc(int aNumMinutes) {
  switch (aNumMinutes) {
    case PERIOD_M1 : return("M1");
    case PERIOD_M15: return("M15");
    case PERIOD_M30: return("M30");
    case PERIOD_H1 : return("H1");
    case PERIOD_H4 : return("H4");
    case PERIOD_D1 : return("D1");
    case PERIOD_W1 : return("W1");
    case PERIOD_MN1: return("MN1");
    case 0: return ("Chart");
    default: return ("M" + aNumMinutes);
  }
}


double getDeMarker(int aShift) {
  return (iDeMarker(NULL, TimeFramePeriod, DeMarkerPeriod, iBarShift(NULL, TimeFramePeriod, Time[aShift])));
}


int start() {

  for(int shift=Bars-1;shift>=0;shift--)
  {
  
    buff[shift] = getDeMarker(shift);
    
  }

  return(0);
 
}
Reply With Quote