#property copyright "Copyright © 2011, Christian Payne" #property link "http://christianpayne.com.au" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Blue //---- input parameters //---- buffers double PinBar[]; static datetime alert.allowed; string msg; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicator buffers mapping SetIndexBuffer(0,PinBar); //---- drawing settings SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,217); //---- SetIndexEmptyValue(0,0.0); //---- name for DataWindow SetIndexLabel(0,"Pin bar"); //---- initialization done return(0); } int deinit() { //---- ObjectsDeleteAll(); int err = 0; err=GetLastError(); if (err != 0) { //Alert(Symbol() + " error ib1: (",err,")"); } return(0); } int start() { int i,nCountedBars; // http://docs.mql4.com/customind/IndicatorCounted nCountedBars = IndicatorCounted(); //---- last counted bar will be recounted if(nCountedBars<=2) i=Bars-nCountedBars-3; if(nCountedBars>2) { nCountedBars--; i=Bars-nCountedBars-1; } int j = 0; while(i>=1) { if (IsPin(Open[i], High[i], Low[i], Close[i])) { PinBar[i] = Low[i] - (50 * Point); } i --; } if (IsPin(Open[1], High[1], Low[1], Close[1]) && CurTime() >= alert.allowed) { alert.allowed = CurTime() + 10*60; // No more alerts for 10 minutes msg = "Pin Bar Trigger - " + Symbol() + " " + TimeToStr(CurTime(), TIME_DATE) + ":" + TimeToStr(CurTime(), TIME_SECONDS); //SendMail("Pin Bar Trigger - " + Symbol(), msg); Alert(msg); } return(0); } bool IsPin(double open, double high, double low, double close) { double head = 0; double body = 0; double tail = 0; double length = 0; double temp = 0; if (open > close) { head = high - open; body = open - close; tail = close - low; } else { head = high - close; body = close - open; tail = open - low; } if (head > tail) { temp = head; head = tail; tail = temp; } length = high - low; if (head / length < 0.2) { if (body / length < 0.3) { if (tail / length > 0.6) { return (true); } } } /* if (((open - high) / (high - low) < 0.2 && (open - high) / (high - low) > -0.2) || ((open - high) / (high - low) > 0.68 || (open - high) / (high - low) < -0.68)) { // if ((open - low) / (high - low) > 0.3 || (open - low) / (high - low) < -0.3) if (1==1) { if ((open - close) / (high - low) < 0.3 && (open - close) / (high - low) > -0.3) { if (((high - close) / (high - low) < 0.3 && (high - close) / (high - low) > -0.3) || ((high - close) / (high - low) > 0.7 || (high - close) / (high - low) < -0.7)) { return (true); } } } } re turn (false) ; */ }