//+------------------------------------------------------------------+ //| //| //+------------------------------------------------------------------+ #property copyright "2010 FxWolfPack" #property link "alex the bird" #property indicator_chart_window int Lookback_Period = 1440; int Buy_At_Low_Plus = 15; int Sell_At_High_Minus = 15; extern int ShiftDayBar = 1; //num of day bars back shift extern int StopLossPips = 10; extern int EntryOffsetPercent = 25; extern bool ViewComment = true; double period_Low=0; double period_High=0; double Period_Low_Line; double Period_High_Line; double Buy_Line=0; double Sell_Line=0; double BuyAt = 0; double SellAt =0; double HighAt = 0; double LowAt =0; double D_High,D_Low,DiffHighLowPips,DiffHighLow4,HighBoundPrice,HighBoundTP,HighBoundSL,LowBoundPrice,LowBoundTP,LowBoundSL; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete("BuyAt Label"); ObjectDelete("BuyAt Line"); ObjectDelete("SellAt Label"); ObjectDelete("SellAt Line"); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //trading range of highest hig-hlowest low withing given num of bars. period_High =High[Highest(NULL,0,MODE_HIGH,Lookback_Period,1)]; period_Low =Low[Lowest(NULL,0,MODE_LOW,Lookback_Period,1)]; Period_Low_Line = (period_Low ); Period_High_Line = (period_High ); Buy_Line = (period_Low + Buy_At_Low_Plus * Point ); Sell_Line = (period_High - Sell_At_High_Minus * Point ); D_High = iHigh(Symbol(),PERIOD_D1,ShiftDayBar); D_Low = iLow(Symbol(), PERIOD_D1,ShiftDayBar); DiffHighLowPips = NormalizeDouble((D_High-D_Low)/Point ,0); DiffHighLow4 = NormalizeDouble(DiffHighLowPips*EntryOffsetPercent/100 ,0); HighBoundPrice = NormalizeDouble(D_High+DiffHighLow4*Point,Digits); HighBoundTP = NormalizeDouble(HighBoundPrice+DiffHighLow4*Point,Digits); HighBoundSL = NormalizeDouble(HighBoundPrice-StopLossPips*Point,Digits); LowBoundPrice = NormalizeDouble(D_Low-DiffHighLow4*Point,Digits); LowBoundTP = NormalizeDouble(LowBoundPrice-DiffHighLow4*Point,Digits); LowBoundSL = NormalizeDouble(LowBoundPrice+StopLossPips*Point,Digits); Buy_Line = HighBoundPrice; Sell_Line = LowBoundPrice; if (ViewComment==true) { ChartComment(); } SetLevel("High Line", D_High, Blue); //Blue SetLevel("Low Line", D_Low, Blue); //Blue SetLevel("Daily Buy line", Buy_Line, Green); //Green SetLevel("Daily Sell line", Sell_Line, Yellow); //Red return(0); } //+------------------------------------------------------------------+ //| Helper | //+------------------------------------------------------------------+ void SetLevel(string text, double level, color col1) { string labelname= text + " Label"; string linename= text + " Line"; if (ObjectFind(labelname) != 0) { ObjectCreate(labelname, OBJ_TEXT, 0, Time[20], level); ObjectSetText(labelname, " " + text, 8, "Arial", White); } else { ObjectMove(labelname, 0, Time[20], level); } if (ObjectFind(linename) != 0) { ObjectCreate(linename, OBJ_HLINE, 0, Time[40], level); ObjectSet(linename, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(linename,OBJPROP_LEVELWIDTH, 5); ObjectSet(linename, OBJPROP_COLOR, col1); } else { ObjectMove(linename, 0, Time[40], level); } } void ChartComment() { string sComment = ""; string sp = "----------\n"; string NL = "\n"; string text1; sComment = sComment+"D1_Open = "+DoubleToStr(iOpen(Symbol(),PERIOD_D1,ShiftDayBar),Digits)+NL; sComment = sComment+"D1_Close= "+DoubleToStr(iClose(Symbol(),PERIOD_D1,ShiftDayBar),Digits)+NL; sComment = sComment+sp; sComment = sComment+"D1_High= "+DoubleToStr(D_High,Digits)+NL; sComment = sComment+"D1_Low = "+DoubleToStr(D_Low,Digits) +NL; sComment = sComment+"DiffPips= "+DoubleToStr(DiffHighLowPips,0)+NL; sComment = sComment+"Diff/4 = "+DoubleToStr(DiffHighLow4,0)+NL; sComment = sComment+sp; sComment = sComment+"BUY Price= "+DoubleToStr(HighBoundPrice,Digits)+NL; sComment = sComment+"BUY TP = "+DoubleToStr(HighBoundTP,Digits)+NL; sComment = sComment+"BUY SL = "+DoubleToStr(HighBoundSL,Digits)+NL; sComment = sComment+sp; sComment = sComment+"SELL Price= "+DoubleToStr(LowBoundPrice,Digits)+NL; sComment = sComment+"SELL TP = "+DoubleToStr(LowBoundTP,Digits)+NL; sComment = sComment+"SELL SL = "+DoubleToStr(LowBoundSL,Digits)+NL; sComment = sComment+sp; sComment = sComment+"Current Time : "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS) + " DayOfWeek : " + TimeDayOfWeek(TimeCurrent()) + " Remaining Time to next Bar : "+TimeToStr(Time[0]+Period()*60-TimeCurrent(),TIME_SECONDS) + NL; sComment = sComment+sp; Comment(sComment); }