//+------------------------------------------------------------------+ //| Support and Resistance Heat Map.mq4 | //| Copyright c 2009, Ronald Raygun | //| | //+------------------------------------------------------------------+ #property copyright "Copyright c 2009, Ronald Raygun" #property link "" #property indicator_chart_window //---- input parameters extern color RedValue1 = Red; extern color GreenValue1 = Green; extern double Multiplier = 10.0; extern double MaxPriceUsed = 0.0; extern double MinPriceUsed = 0.0; extern int MaxBars = 0; extern int BarsShift = 0; extern int Step = 1; // value to control roughness (to reduce hline-step) extern double ColorMultiplier = 256; double Ratio = 0.0; int DQ_ADJUST [] = { 0 , 0 , 1 , 1 , 1 , 1 , 1 }; int DQADJ; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { DQADJ = DQ_ADJUST [ Digits ]; // DQADJ is adjustment for deci-quotes (3-5 digits) brokers start(); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- for (int j = ObjectsTotal(); j >= 0; j--) { string OriginalName = ObjectName(j); if(0 == StringFind(OriginalName, StringConcatenate("S/R EA: ", Symbol(), " ", Period()))) { ObjectDelete(ObjectName(j)); } } ObjectDelete("StartingBar"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); double MaxPrice; double MinPrice; int BarsUsed; if(MaxPriceUsed == 0) MaxPrice = WindowPriceMax(); else MaxPrice = MaxPriceUsed; if(MinPriceUsed == 0) MinPrice = WindowPriceMin(); else MinPrice = MinPriceUsed; if(MaxBars == 0) BarsUsed = WindowBarsPerChart() + BarsShift; else BarsUsed = MaxBars + BarsShift; ObjectDelete("StartingBar"); ObjectCreate("StartingBar", OBJ_VLINE, 0, Time[BarsUsed], 0); ObjectSet("StartingBar", OBJPROP_COLOR, Aqua); ObjectSet("StartingBar", OBJPROP_STYLE, STYLE_DASH); ObjectDelete("ShiftBar"); ObjectCreate("ShiftBar", OBJ_VLINE, 0, Time[BarsShift], 0); ObjectSet("ShiftBar", OBJPROP_COLOR, Aqua); ObjectSet("ShiftBar", OBJPROP_STYLE, STYLE_DASH); if(BarsShift == 0) ObjectDelete("ShiftBar"); int CrossCount = 0; int CountsCrossed = 0; Ratio = 0.0; int Roughness = DQADJ*Step; double PriceStep = ( (MaxPrice - MinPrice) / Point )/Roughness; for (int i=0; i= Price_i && Low[k] <= Price_i ) CrossCount++; } CountsCrossed = CrossCount; double CC = CrossCount*Step; double BU = BarsUsed; Ratio = CC / BU * Multiplier; double d_RedValue = RedValue1 * Ratio; int RedValue = d_RedValue; if(Ratio > 1) RedValue = RedValue1; int GreenValue = RedValue1 - RedValue; color LineColor = (RedValue + GreenValue * ColorMultiplier); ObjectSet(ObjName, OBJPROP_COLOR, LineColor); ObjectSet(ObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(ObjName, OBJPROP_BACK, true); Ratio = 0; CrossCount = 0; } return(0); } //+------------------------------------------------------------------+ //| D2STR //+------------------------------------------------------------------+ string D2STR(double Price) { return( DoubleToStr(Price,Digits) ); }