//+--------------------------------------------------------------------------------------------+ //| P&F_v2.mq4 //+--------------------------------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 Blue #property indicator_color2 Blue #property indicator_color3 Green #property indicator_color4 Crimson #property indicator_color5 EMPTY extern int BoxSize = 20; extern int Reversal = 3; extern int ShowBars = 500; double UpTrend[]; double DownTrend[]; double UpSignal[]; double DownSignal[]; double Trend[]; int init() { IndicatorBuffers(5); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); SetIndexEmptyValue(0,0.0); SetIndexBuffer(0,UpTrend); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); SetIndexEmptyValue(1,0.0); SetIndexBuffer(1,DownTrend); SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,1); SetIndexArrow(2,233); SetIndexEmptyValue(2,0.0); SetIndexBuffer(2,UpSignal); SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,1); SetIndexArrow(3,234); SetIndexEmptyValue(3,0.0); SetIndexBuffer(3,DownSignal); SetIndexStyle(4,DRAW_NONE); SetIndexEmptyValue(4,0.0); SetIndexBuffer(4,Trend); return(0); } int deinit() { return(0); } int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); //---- check for possible errors if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted for (int i=Bars-counted_bars;i>=0;i--) { if (ShowBars == 0 || (ShowBars > 0 && i <= ShowBars)) { if (Trend[i+1] == 0) { if (Low[i]+(BoxSize*Point) < High[i]) { DownTrend[i] = Low[i]; UpTrend[i] = High[i]; Trend[i] = -1; DownSignal[i] = High[i]+(5*Point); } else if (High[i]-(BoxSize*Point) > Low[i]) { DownTrend[i] = Low[i]; UpTrend[i] = High[i]; Trend[i] = 1; UpSignal[i] = Low[i]-(5*Point); } else { DownTrend[i] = DownTrend[i+1]; UpTrend[i] = UpTrend[i+1]; Trend[i] = Trend[i+1]; } } else if (Trend[i+1] == -1) { if (Low[i]+(BoxSize*Point) < DownTrend[i+1]) { DownTrend[i] = Low[i]; UpTrend[i] = UpTrend[i+1]; Trend[i] = Trend[i+1]; } else if (High[i] > DownTrend[i+1]+((BoxSize*Point)*Reversal)) { UpTrend[i] = High[i]; DownTrend[i] = Low[i]; Trend[i] = 1; UpSignal[i] = Low[i]-(5*Point); } else { DownTrend[i] = DownTrend[i+1]; UpTrend[i] = UpTrend[i+1]; Trend[i] = Trend[i+1]; } } else if (Trend[i+1] == 1) { if (High[i]-(BoxSize*Point) > UpTrend[i+1]) { DownTrend[i] = DownTrend[i+1]; UpTrend[i] = High[i]; Trend[i] = Trend[i+1]; } else if (Low[i] < UpTrend[i+1]-((BoxSize*Point)*Reversal)) { UpTrend[i] = High[i]; DownTrend[i] = Low[i]; Trend[i] = -1; DownSignal[i] = High[i]+(5*Point); } else { DownTrend[i] = DownTrend[i+1]; UpTrend[i] = UpTrend[i+1]; Trend[i] = Trend[i+1]; } } } } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW
Implements a curve of type DRAW_NONE
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: