//+------------------------------------------------------------------+ //| 3 MAs Cross Arrows.mq4 | //| Copyright © 2006 Scorpion@fxfisherman.com | //+------------------------------------------------------------------+ #property copyright "FxFisherman.com" #property link "http://www.fxfisherman.com" #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 Magenta #property indicator_color2 Yellow #property indicator_color3 DarkTurquoise #property indicator_color4 Red #property indicator_color5 White #property indicator_width1 5 #property indicator_width2 5 extern int MA1_Period = 20; extern int MA1_Type = 0; extern int MA2_Period = 20; extern int MA2_Type = 0; extern int MA3_Period = 5; extern int MA3_Type = 0; extern int Shift_Bars=0; extern int Bars_Count= 10000; //---- buffers double v1[]; double v2[]; double v3[]; double v4[]; double v5[]; double alertBar; int init() { IndicatorBuffers(5); SetIndexArrow(0,218); // 234 SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID); SetIndexDrawBegin(0,-1); SetIndexBuffer(0, v1); SetIndexLabel(0,"Buy"); SetIndexArrow(1,217);// 233 SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID); SetIndexDrawBegin(1,-1); SetIndexBuffer(1, v2); SetIndexLabel(1,"Sell"); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1); SetIndexDrawBegin(2,-1); SetIndexBuffer(2, v3); SetIndexLabel(2,"MA1"); SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1); SetIndexDrawBegin(3,-1); SetIndexBuffer(3, v4); SetIndexLabel(3,"MA2"); SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1); SetIndexDrawBegin(4,-1); SetIndexBuffer(4, v5); SetIndexLabel(4,"MA3"); return(0); } int start() { double ma1, ma2, ma3; int previous; int i; int shift; bool crossed_up, crossed_down; int counted_bars = IndicatorCounted(); if (counted_bars > 0) counted_bars--; if (Bars_Count > 0 && Bars_Count <= Bars) { i = Bars_Count - counted_bars; }else{ i = Bars - counted_bars; } while(i>=0) { shift = i + Shift_Bars; ma1 = iMA(Symbol(), Period(), MA1_Period, 0, MA1_Type, PRICE_HIGH, shift); ma2 = iMA(Symbol(), Period(), MA2_Period, 0, MA2_Type, PRICE_LOW, shift); ma3 = iMA(Symbol(), Period(), MA3_Period, 0, MA3_Type, Close, shift); Comment(ma1, " ", ma2, " ", ma3); crossed_up = (ma1 > ma3 && ma2 > ma3); crossed_down = (ma1 < ma3 && ma2 < ma3); v3[i] = ma1; v4[i] = ma2; v5[i] = ma3; if (crossed_up && previous != 1) { v1[i] = Open[shift]; previous = 1; if(Bars>alertBar) {Alert("3Ma's Alert changing Up " + Symbol() + " on the " + Period() + " minute chart.");alertBar = Bars;} }else if(crossed_down && previous != 2){ v2[i] = Open[shift]; previous = 2; if(Bars>alertBar) {Alert("3Ma's Alert changing Down " + Symbol() + " on the " + Period() + " minute chart.");alertBar = Bars;} } i--; } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_ARROW
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen