百变霹雳小小招财猫!
大型投行
- 金钱
- 36815 美元
- 权重
- 437 股
|
本帖最后由 wccmcd 于 2015-12-4 12:05 编辑
下载请回复,金币的不要,谢谢。
RR_Support and Resistance Heat Mapv1.mq4
(4.37 KB, 下载次数: 49)
代码:
- //+------------------------------------------------------------------+
- //| 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 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)
- 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;
- Print( "PriceStep = "+PriceStep );
- for (int i=0; i<PriceStep; i++)
- {
- double Price_i = MinPrice + (i *Roughness * Point);
- string ObjName = StringConcatenate("S/R EA: ", Symbol(), " ", Period(), " ", D2STR(Price_i));
- ObjectDelete(ObjName);
- ObjectCreate(ObjName, OBJ_TREND, 0, Time[BarsUsed], Price_i, Time[BarsShift], Price_i);
- for (int k=0; k<BarsUsed; k++)
- {
- if(High[k] >= Price_i && Low[k] <= Price_i ) CrossCount++;
- }
- CountsCrossed = CrossCount;
- double CC = CrossCount*Step;
- double BU = BarsUsed;
- Ratio = CC / BU * Multiplier;
- Print("Ratio: ", DoubleToStr(Ratio,2));
- Print("CrossCount: ", CrossCount);
- Print("BarsUsed: ", BarsUsed);
- double d_RedValue = 255 * Ratio;
- int RedValue = d_RedValue;
- if(Ratio > 1) RedValue = 255;
-
- int GreenValue = 255 - RedValue;
-
- color LineColor = (RedValue + GreenValue * 256);
- 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) );
- }
复制代码
|
|