//+------------------------------------------------------------------+ //| MA DISTANCING INDICATOR | //| | //| Copyright © 2008, Tim Hyder aka Hiachiever | //| | //| PO BOX 768, Hillarys, Western Australia, Australia, 6923 | //| | //| CUSTOMISED MQ4 DEVELOPMENT | //| I am available for customised MQ4 development work. Please | //| contact me at hiachiever@gmail.com, to discuss your coding | //| requirements. My rates are very reasonable and most jobs are | //| a fixed price quote. | //| | //| GIFTS AND DONATIONS ACCEPTED | //| All my indicators should be considered donationware. That is | //| you are free to use them for your personal use, and are | //| under no obligation to pay for them. However, if you do find | //| this or any of my other indicators help you with your trading | //| then any Gift or Donation as a show of appreciation is | //| gratefully accepted. | //| | //| Gifts or Donations also keep me motivated in producing more | //| great free indicators. :-) | //| | //| PayPal - hiachiever@gmail.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, Tim Hyder." #property link "hiachiever@gmail.com" #define vers "08-May-2008" #define major 1 #define minor 0 #property indicator_chart_window extern string MOVAVG = " --- MOVING AVERAGE SETTINGS --- "; extern int MA.Period = 5; extern int MA.Method = MODE_EMA; extern int MA.Price = PRICE_CLOSE; extern bool UseTickdata = True; extern string DISTANCEA = " --- MOVING AVERAGE DISTANCING --- "; extern int MA.Distance = 10; extern color GreaterThanDistance = Red; extern color LessThanDistance = Aqua; extern int FontSize = 10; extern int MoveUPDN = 20; extern int MoveLeftRight = 20; string prefix = "MAD_"; //references to this need to be removed from the code - when I have time bool Corner_of_Chart_RIGHT_TOP = False; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { int total = ObjectsTotal(); for (int i=total-1; i >= 0; i--) { string name = ObjectName(i); if (StringFind(name, prefix) == 0) ObjectDelete(name); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { string LblText = "-"; color LblColor; int Shift = 1; if(UseTickdata) Shift = 0; double MA = iMA(Symbol(),Period(),MA.Period, 0, MA.Method, MA.Price, Shift); int DiFF = (Close[Shift] - MA)/Point; LblColor = GreaterThanDistance; if (MathAbs(DiFF)<MA.Distance) LblColor = LessThanDistance; CreateLabel(prefix+"1", "Difference between " + DoubleToStr(MA.Period,0) + " period MA and Price is " + DoubleToStr(DiFF,0) + " pips.", FontSize, "Arial Bold", LblColor, Corner_of_Chart_RIGHT_TOP,MoveLeftRight,MoveUPDN); return(0); } //+------------------------------------------------------------------+ void CreateLabel(string LblName, string LblTxt, double FontSz, string FontName, color FontColor, int Corner, int xPos, int yPos) { if(ObjectFind(LblName) != 0) ObjectCreate(LblName, OBJ_LABEL, 0, 0, 0); ObjectSetText(LblName, LblTxt, FontSz, FontName, FontColor); ObjectSet(LblName, OBJPROP_CORNER, Corner); ObjectSet(LblName, OBJPROP_XDISTANCE, xPos); ObjectSet(LblName, OBJPROP_YDISTANCE, yPos); }
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: