//+------------------------------------------------------------------+ //| 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 White #property indicator_color2 White #property indicator_color3 Blue #property indicator_color4 Red #property indicator_color5 Red extern int MA1_Period = 5; extern int MA1_Type = 1; extern int MA2_Period = 10; extern int MA2_Type = 1; extern int MA3_Period = 34; extern int MA3_Type = 1; extern int Shift_Bars=0; extern int Bars_Count= 10000; //---- buffers double v1[]; double v2[]; double v3[]; double v4[]; double v5[]; int init() { IndicatorBuffers(5); SetIndexArrow(0,217); SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1); SetIndexDrawBegin(0,-1); SetIndexBuffer(0, v1); SetIndexLabel(0,"Buy"); SetIndexArrow(1,218); SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1); 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"); watermark(); 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_CLOSE, shift+1); ma2 = iMA(Symbol(), Period(), MA2_Period, 0, MA2_Type, PRICE_CLOSE, shift+1); ma3 = iMA(Symbol(), Period(), MA3_Period, 0, MA3_Type, PRICE_CLOSE, shift+1); 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; }else if(crossed_down && previous != 2){ v2[i] = Open[shift]; previous = 2; } i--; } return(0); } //+------------------------------------------------------------------+ void watermark() { ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0); ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue); ObjectSet("fxfisherman", OBJPROP_CORNER, 2); ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5); ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10); 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: