//+------------------------------------------------------------------+ //| Median-HL.mq4 | //| FX_Kuraisora Copyright 2012 MetaQuotes Software Corp. | //| http://goldsearch.blog24.fc2.com/ | //+------------------------------------------------------------------+ #property copyright "FX_Kuraisora Copyright 2012 MetaQuotes Software Corp." #property indicator_chart_window #property indicator_buffers 5 // extern int TF = 0;//タイムフレーム Timeframe 0,1,5,15,30,60,240,1440,10080,43200 extern color Color_HH = Blue; extern color Color_UM = RoyalBlue; extern color Color_ML = Red; extern color Color_DM = RoyalBlue; extern color Color_LL = Blue; extern bool Show_PriceBox = true;//価格表示 Price-view ON-OFF extern int PriceBox_Width = 2; extern int PriceBox_Shift = 5; extern bool PriceBox_Back = false; //---- buffers double HH[]; double LL[]; double Median[]; double UM[]; double DM[]; double HH1; double LL1; double Median1; double UM1; double DM1; // int init() { SetIndexBuffer(0,HH); SetIndexStyle(0,DRAW_LINE,EMPTY,EMPTY,Color_HH); SetIndexBuffer(1,UM); SetIndexStyle(1,DRAW_LINE,STYLE_DOT,EMPTY,Color_UM); SetIndexBuffer(2,Median); SetIndexStyle(2,DRAW_LINE,STYLE_DOT,EMPTY,Color_ML); SetIndexBuffer(3,DM); SetIndexStyle(3,DRAW_LINE,STYLE_DOT,EMPTY,Color_DM); SetIndexBuffer(4,LL); SetIndexStyle(4,DRAW_LINE,EMPTY,EMPTY,Color_LL); return(0); } // int deinit() { ObjectDelete("1"); ObjectDelete("2"); ObjectDelete("3"); ObjectDelete("4"); ObjectDelete("5"); return(0); } // int start() { int counted_bars=IndicatorCounted(); int limit =Bars-counted_bars-1; int i; for(i=limit;i>=0;i--){ HH1 = High[iHighest(NULL,TF,MODE_CLOSE)]; LL1 = Low[iLowest(NULL,TF,MODE_CLOSE)]; UM1=Median1+((HH1-Median1)*0.62); Median1=(HH1+LL1)/2; DM1=Median1-((Median1-LL1)*0.62); HH[i]=HH1; LL[i]=LL1; Median[i]=Median1; UM[i]=UM1; DM[i]=DM1; } Comment("HH=",HH1," LL=",LL1," Median=",Median1); //----------Price Box if(Show_PriceBox){ datetime PB_sift = Time[0] + PriceBox_Shift * Period() * 60; SetPrice("1", PB_sift, HH[0], Color_HH, PriceBox_Width, PriceBox_Back); SetPrice("2", PB_sift, UM[0], Color_UM, PriceBox_Width, PriceBox_Back); SetPrice("3", PB_sift, Median[0], Color_ML, PriceBox_Width, PriceBox_Back); SetPrice("4", PB_sift, DM[0], Color_DM, PriceBox_Width, PriceBox_Back); SetPrice("5", PB_sift, LL[0], Color_LL, PriceBox_Width, PriceBox_Back); } else { ObjectDelete("1"); ObjectDelete("2"); ObjectDelete("3"); ObjectDelete("4"); ObjectDelete("5"); } return(0); } /////////////////////////////////////////////////////////////////////// void SetPrice(string ID, datetime Tm, double Prc, color clr, int size, bool Back) { if(ObjectFind(ID) == -1){ ObjectCreate(ID, OBJ_ARROW, 0, Tm, Prc); ObjectSet(ID, OBJPROP_COLOR, clr); ObjectSet(ID, OBJPROP_WIDTH, size); ObjectSet(ID, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); ObjectSet(ID, OBJPROP_BACK, Back); } else { ObjectSet(ID, OBJPROP_TIME1, Tm); ObjectSet(ID, OBJPROP_PRICE1, Prc); ObjectSet(ID, OBJPROP_COLOR, clr); ObjectSet(ID, OBJPROP_WIDTH, size); ObjectSet(ID, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); ObjectSet(ID, OBJPROP_BACK, Back); } return(0); } /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------+