//+------------------------------------------------------------------+ //| PowerTrend MultiTimeFrame Stochastic | //| | //| Copyright © 2008, Tim Hyder aka Hiachiever | //| | //| PO BOX 768, Hillarys, Western Australia, Australia, 6923 | //| | //| 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 "http://www.the4xtrader.com" #define vers "18.Feb.2008" #define major 1 #define minor 0 #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 7 #property indicator_buffers 4 #property indicator_color1 Aqua //Stoch.Trending.Up #property indicator_color2 Red //Stoch.Trending.Dn #property indicator_color3 Blue //Stoch.Overbought #property indicator_color4 Maroon //Stoch.Oversold extern string NOTE1 = " --- TimeFrame Settings ---"; extern string NOTETF = "Enter 0 to display current TF"; extern int TimeFrame = 0; extern string NOTE2 = " --- Display Settings ---"; extern string NOTEVS = "Vertically positions indicator"; extern int VertShift = 1; extern string NOTESTOCH = " --- Stochastic Settings ---"; extern int Stoch.Period = 5; extern double Stoch.Kfast = 3; // Sensivity Factor for Fast Line extern double Stoch.Kslow = 3; // Sensivity Factor for Slow Line extern string NOTEDISPLAY = " --- Other Display options ---"; extern int MaxBars = 1000; extern string DISPLAYFVS1 = "FineVertShift allows Time Frame label"; extern string DISPLAYFVS2 = "to be moved up and down"; extern double TFLabelVS = -0.6; //colour of time frame label on far right of indicator extern color TFTextColor = White; extern color TFSameTFColor = Lime; extern int TFTextFontSize = 6; extern string NOTEALERTS = " --- Alerts ---"; extern bool AllowTextAlerts = false; extern bool AllowSoundAlerts = false; extern string LongSound = "alert3.wav"; extern string ShortSound = "alert4.wav"; extern bool AllowEmailAlerts = false; //---- buffers double bufUpTrend[], bufOverBought[] ; double bufDnTrend[], bufOverSold[]; string ShortName = ""; string Prefix = "MTF-STOCH"; int ArrowSize = 110; int BarWidth = 0; datetime LastTime = -1; int TFrame, Window; //Four constants used in one of the functions below int Stoch.UpTrend = 1, Stoch.DnTrend = 2, Stoch.OverBought = 3, Stoch.OverSold = 4; //--------------------------------------------------------------------------------------------------------------- void init() { IndicatorBuffers(4); SetIndexStyle(0, DRAW_ARROW, 0, BarWidth); SetIndexStyle(1, DRAW_ARROW, 0, BarWidth); SetIndexStyle(2, DRAW_ARROW, 0, BarWidth); SetIndexStyle(3, DRAW_ARROW, 0, BarWidth); SetIndexArrow(0, ArrowSize); SetIndexArrow(1, ArrowSize); SetIndexArrow(2, ArrowSize); SetIndexArrow(3, ArrowSize); SetIndexBuffer(0, bufUpTrend); SetIndexBuffer(1, bufDnTrend); SetIndexBuffer(2, bufOverBought); SetIndexBuffer(3, bufOverSold); SetIndexEmptyValue(0, 0.0); SetIndexEmptyValue(1, 0.0); SetIndexEmptyValue(2, 0.0); SetIndexEmptyValue(3, 0.0); SetIndexLabel(0, NULL); SetIndexLabel(1, NULL); SetIndexLabel(2, NULL); SetIndexLabel(3, NULL); IndicatorDigits(0); //Verify Time Values entered by user TFrame = CheckTimeFrame(TimeFrame); //---- name for DataWindow and indicator subwindow label //VertShift = GetNextIndicatorNo(Prefix); ShortName = Prefix + VertShift; IndicatorShortName(ShortName); } void deinit() { int total = ObjectsTotal(); for (int i=total-1; i >= 0; i--) { string name = ObjectName(i); if (StringFind(name, Prefix) == 0) ObjectDelete(name); } } void start() { int i,tf,x,y=0; datetime TimeArray[]; int Stoch; Window = WindowFind(ShortName); //This indicator is designed to display mutliple TFs in 1 indicator Window //When suqsequent indicators are dropped on the same Window //as a previous one WindowFind returns -1 ie can't find it. //This loop is to loop through the windows and find the window reference //The purpose behind all of this is to fix the problem of the TF labels //not being displayed for indicator 2,3,4 etc because of the Window reference if (Window == -1) { for (i=0; i<20; i++) { x = WindowFind(Prefix + i); if (x > 0) { Window = x; break; } } } int counted_bars=IndicatorCounted(); //---- check for possible errors if (counted_bars < 0) return(-1); //---- the last counted bar will be recounted if (counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; limit = MathMin(limit, MaxBars); //-------------------------------1---------------------------------------- // Plot defined time frame on to current time frame ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); for(i=0,y=0;i Red if (bufOverBought[bar] != 0 && bufOverBought[bar+1] == 0) { msg = msg + " is now Oversold."; if (AllowTextAlerts) Alert(msg); if (AllowSoundAlerts) PlaySound(ShortSound); if (AllowEmailAlerts) SendMail(MailSubject, msg); } //<- Red if (bufOverBought[bar] == 0 && bufOverBought[bar+1] != 0) { msg = msg + " has started new up trend."; if (AllowTextAlerts) Alert(msg); if (AllowSoundAlerts) PlaySound(ShortSound); if (AllowEmailAlerts) SendMail(MailSubject, msg); } LastTime = Time[0]; } return(0); } void CreateTFLabel(int TF) { string txt = TF2Str(TF); double TimeDiff = Time[0]-Time[1]; string name = Prefix+VertShift+"_TF_"+txt; color labelcolor = TFTextColor; string fontname = "Arial"; //If Tf = Chart Period change TF Label colour so that it can be easily identified if (TF == Period()) { labelcolor = TFSameTFColor; fontname = "Arial Bold"; TFLabelVS = -0.7; } if(VertShift= stoch_sig) && (stoch_main >= 20) && (stoch_main <= 80)) return (Stoch.UpTrend); else if (stoch_main > 80) return (Stoch.OverBought); else if ((stoch_main <= stoch_sig) && (stoch_main >= 20) && (stoch_main <= 80)) return (Stoch.DnTrend); else if (stoch_main < 20) return (Stoch.OverSold); }