//+------------------------------------------------------------------+ //| TDI Alerts v4.mq4 | //| previous name: TDI-With Alerts | //| | //| (since there are so many versions around, imho the | //| renaming makes sense, Marc) | //| | //| Version 1. Completed by Dean Malone 2006 (www.compassfx.com) | //| Version 2. Completed by Tim Hyder 2008 | //| a) Complete Code rewrite | //| b) Added Entry / Exit Signal Arrows Option | //| b) Added Audio, Visual and eMail alerts | //| Version 2.a Completed by Marc (fxdaytrader), forexBaron.net | //| a) Added/mod. Alertmodes (sound/push/texts) | //| b) Added ma-parameters (trend-signal-shift,etc. | //| c) Made the colors changeable (external params) | //| d) Made the ob/os/cons levels changeable | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Version 4. Completed By Jim Hodges January,5,2016 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a) Updated code to latest version of MT4 b) Invoked #property strict for strict compiling c) Corrected numerous bugs to allow clean compiling d) Replaced init()with OnInit() function e) Replaced deinit() with OnDeinit() f) Replaced start() with OnCalculate() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ //+------------------------------------------------------------------+ //| Explanation of Indicator Usage | //+------------------------------------------------------------------+ //| Traders Dynamic Index - Overview | //| | //| Introduction | //| ------------ | //| The TDI indicator was developed by Dean Malone (CompassFx.com) | //| in 2006 and rewritten by Tim Hyder aka Hiachiever | //| (hiachiever@gmail.com) in 2008. Finally it got the final touch | //| (to date?) in 2013 by Marc aka fxdaytrader (www.forexBaron.net). | //| | //| Let us listen to Dean's explanation about the functional | //| principle of the Traders Dynamic Index: | //| | //| This hybrid indicator is developed to assist traders in their | //| ability to decipher and monitor market conditions related to | //| trend direction, market strength, and market volatility. | //| | //| Even though comprehensive, the T.D.I. is easy to read and use. | //| | //| Green line = RSI Price line | //| Red line = Trade Signal line | //| Blue lines = Volatility Band | //| Yellow line = Market Base Line | //| | //| Trend Direction - Immediate and Overall | //| --------------------------------------- | //| Immediate = Green over Red...price action is moving up. | //| Red over Green...price action is moving down. | //| | //| Overall = Yellow line trends up and down generally between the | //| lines 32 & 68. Watch for Yellow line to bounces off | //| these lines for market reversal. Trade long when | //| price is above the Yellow line, and trade short when | //| price is below. | //| | //| Market Strength & Volatility - Immediate and Overall | //| Immediate = Green Line - Strong = Steep slope up or down. | //| Weak = Moderate to Flat slope. | //| | //| Overall = Blue Lines - When expanding, market is strong and | //| trending. When constricting, market is weak and | //| in a range. When the Blue lines are extremely tight | //| in a narrow range, expect an economic announcement | //| or other market condition to spike the market. | //| | //| | //| Entry conditions //| ---------------- | //| Scalping - Long = Green over Red, Short = Red over Green | //| Active - Long = Green over Red & Yellow lines | //| Short = Red over Green & Yellow lines | //| Moderate - Long = Green over Red, Yellow, & 50 lines | //| Short= Red over Green, Green below Yellow & 50 line | //| | //| Exit conditions* | //| ---------------- | //| Long = Green crosses below Red | //| Short = Green crosses above Red | //| * If Green crosses either Blue lines, consider exiting when | //| when the Green line crosses back over the Blue line. | //| | //| | //| IMPORTANT: The default settings are well tested and proven. | //| ---------- But, you can change the settings to fit your | //| trading style. | //| | //| | //| Price & Line Type settings: | //| RSI Price settings | //| 0 = Close price [DEFAULT] | //| 1 = Open price. | //| 2 = High price. | //| 3 = Low price. | //| 4 = Median price, (high+low)/2. | //| 5 = Typical price, (high+low+close)/3. | //| 6 = Weighted close price, (high+low+close+close)/4. | //| | //| RSI Price Line & Signal Line Type settings | //| 0 = Simple moving average [DEFAULT] | //| 1 = Exponential moving average | //| 2 = Smoothed moving average | //| 3 = Linear weighted moving average | //| | //| Good trading, | //| | //| Dean | //+------------------------------------------------------------------+ /* SIGNAL GENERATION: ------------------ The TDI (Traders Dynamic Index) =============================== Volatility Band High (VB HIGH), color: SkyBlue, buffer: UpZone Volatility Band Low (VB LOW), color: SkyBlue, buffer: DnZone RSI PRICE LINE (RSI), color: Green, buffer: MaBuf MARKET BASE LINE, color: Yellow, buffer: MdZone TRADE SIGNAL LINE, color: Red, buffer: MbBuf TRADE SIGNAL2 LINE, color: Aqua, buffer: McBuf, -> has no function for signal generation! Indicator SignalLevels: RSI_OversoldLevel : 23 (default: 32) RSI_OverboughtLevel : 78 (default: 68) VB_ConsolidationLevel : 20 (default: 20) Conditions: =========== Strong Buy: RSI>TRADE SIGNAL LINE && TRADE SIGNAL LINE> MARKET BASE LINE && RSI>RSI_OversoldLevel && RSITRADE SIGNAL LINE && RSI> MARKET BASE LINE && TRADE SIGNAL LINE< MARKET BASE LINE && RSI>RSI_OversoldLevel && RSITRADE SIGNAL LINE && TRADE SIGNAL LINERSI_OversoldLevel && RSIRSI_OversoldLevel && RSI MARKET BASE LINE && RSI>RSI_OversoldLevel && RSI MARKET BASE LINE && RSI> MARKET BASE LINE && RSI>RSI_OversoldLevel && RSI=RSI_OverboughtLevel LOW LEVEL CAUTION (Oversold): RSI<=RSI_OversoldLevel TrendSignals: ============= Strong Up: TRADE SIGNAL LINE>MARKET BASE LINE Weak Up: TRADE SIGNAL LINE>MARKET BASE LINE && RSI=MARKET BASE LINE Consolidation: VB HIGH-VB LOW=0; i--) { string name=ObjectName(i); if (StringFind(name, prefix)==0) ObjectDelete(name); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnCalculate (const int rates_total, // size of input time series const int prev_calculated, // bars handled in previous call const datetime& time[], // Time const double& open[], // Open const double& high[], // High const double& low[], // Low const double& close[], // Close const long& tick_volume[], // Tick Volume const long& volume[], // Real Volume const int& spread[] // Spread ) { double indicatorVal;//mod. to replace rsi easily, fxdaytrader int Win=WindowFind(indicatorName); if (Win==- 1) Win=0; //---- double MA,RSI[]; ArrayResize(RSI,Volatility_Band); //--- int limit = rates_total-prev_calculated; if (prev_calculated == 0) limit -= Volatility_Band; //---- //////////////////////////////////////////////////////////////// for(int i=limit; i>=0; i--) { //mod if you'd like to replace rsi by something else, eg. stoch: indicatorVal = iRSI(NULL,0,RSI_Period,RSI_Price,i); //default if (UseStochInsteadOfRsi) indicatorVal = iStochastic(NULL,0,stochKPeriod,stochDPeriod,stochSlowing,stochMethod,stochPrice,MODE_MAIN,i); //end mod RSIBuf[i]=indicatorVal; //original: iRSI(NULL,0,RSI_Period,RSI_Price,i); MA=0; for(int x=i; x=0;i--) { MaBuf[i]=(iMAOnArray(RSIBuf,0,RSI_Price_Line,RSI_Price_Line_Shift,RSI_Price_Type,i)); MbBuf[i]=(iMAOnArray(RSIBuf,0,Trade_Signal_Line,Trade_Signal_Line_Shift,Trade_Signal_Type,i)); McBuf[i]=(iMAOnArray(RSIBuf,0,Trade_Signal2_Line,Trade_Signal2_Line_Shift,Trade_Signal2_Type,i)); BidCur=Close[i]; //Could use bid however no good when using visual back tester TimeCur=Time[i]; //CUSTOM ALERT: double filterma = iMA(NULL,0,filterMaPeriod,filterMaShift,filterMaMethod,filterMaPrice,i); double filterprice = iClose(NULL,0,i); string stext; //RSI > MarketBaseLine && RSI > TradeSignal && RSI b4 < TradeSignal b4 if (RsiTradeSignalCrossAlerts) if ((filterprice>filterma && RsiTradeSignalCrossMaFilter)||!RsiTradeSignalCrossMaFilter) if (MaBuf[i]MbBuf[i] && MaBuf[i+1]MdZone[i] && MaBuf[i]>MbBuf[i] && MaBuf[i+1]LastAlertBar && i==AlertBar) { LastAlertBar=Bars; DoAlerts(stext,Symbol()+ ", " + TF2Str(Period()) + ": BUY SIGNAL - PriceLine crossed TradeSignalLine below MarketBaseLine",CustomAlertSoundFileLong); } }//if (RsiTradeSignalCrossAlerts) //RSI < MarketBaseLine && RSI < TradeSignal && RSI b4 > TradeSignal b4 if (RsiTradeSignalCrossAlerts) if ((filterpriceMdZone[i] && MaBuf[i]MbBuf[i+1]) {//new, bear cross above marketbase //if (MaBuf[i]MbBuf[i+1]) {//nellycopter old if (SendTimeInfoAsTimeLocal) MyTime=TimeLocal(); else if (!SendTimeInfoAsTimeLocal) MyTime=TimeCurrent(); stext=Symbol()+ ", " + TF2Str(Period()) + ": SELL SIGNAL - PriceLine crossed TradeSignalLine above MarketBaseLine @ "+DoubleToStr(Close[i],Digits) + ", @ " + TimeToStr(MyTime,TIME_SECONDS); if (Bars>LastAlertBar && i==AlertBar) { LastAlertBar=Bars; DoAlerts(stext,Symbol()+ ", " + TF2Str(Period()) + ": SELL SIGNAL - PriceLine crossed TradeSignalLine above MarketBaseLine",CustomAlertSoundFileShort); } }//if (RsiTradeSignalCrossAlerts) //end CUSTOM ALERT ///////////////////////// if(Show_TrendVisuals) { //signals // "RSI PRICE LINE" > "TRADE SIGNAL LINE" && "TRADE SIGNAL LINE" < "MARKET BASE LINE" && "RSI PRICE LINE" < "MARKET BASE LINE" if((MaBuf[i]>MbBuf[i])&&(MbBuf[i]RSI_OversoldLevel)&&(MaBuf[i] MdZone[i])&&(MaBuf[i]> MdZone[i])&&(MaBuf[i]>RSI_OversoldLevel)&&(MaBuf[i] "TRADE SIGNAL LINE" && "TRADE SIGNAL LINE" > "MARKET BASE LINE" else if((MaBuf[i]>MbBuf[i])&&(MbBuf[i]> MdZone[i])&&(MaBuf[i]>RSI_OversoldLevel)&&(MaBuf[i] "TRADE SIGNAL LINE" else if((MaBuf[i]>MbBuf[i])&&(MaBuf[i]> MdZone[i])&&(MbBuf[i]< MdZone[i])&&(MaBuf[i]>RSI_OversoldLevel)&&(MaBuf[i]RSI_OversoldLevel)&&(MaBuf[i] MdZone[i])&&(MaBuf[i]>RSI_OversoldLevel)&&(MaBuf[i]=RSI_OverboughtLevel) { Signal2="Caution - Overbought !"; Signal="ê"; TDI_col=StrongBuyArrowCautionColor;//HighLevelCautionColor; } else if(MaBuf[i]<=RSI_OversoldLevel) { Signal2="Caution - Oversold !"; Signal="é"; TDI_col=StrongSellArrowCautionColor;//LowLevelCautionColor; } //TDI - Trend Signals if((MbBuf[i]>MdZone[i])&&(MaBuf[i]MdZone[i]) { Signal4= "Strong Up"; Signal3="é"; TDI_col2=StrongUpColor; } if((MbBuf[i]<=MdZone[i])&&(MaBuf[i]>=MdZone[i])) { Signal4= "Weak Down"; Signal3="é"; TDI_col2=WeakDownColor; } else if (MbBuf[i]<=MdZone[i]) { Signal4= "Strong Down"; Signal3="ê"; TDI_col2=StrongDownColor; } //ranging if(UpZone[i]-DnZone[i]LastAlertBar && i==AlertBar) { LastAlertBar=Bars; if (StrongBuySellAlerts) DoAlerts(Msg,Subj,SoundAlertFileLong); } LastAlert=1; //Last trend Alert was Up Trend Buy Alert //---- if (Show_SignalArrows)//BUY { CreateText(prefix+"En"+(string)SigCounter,0," B",10,"Arial Bold",BuyArrowColor,Time[i],Low[i]-SignalArrowSpacer(),false); SigCounter++; } //Print("Text: " + TimeToStr(Time[i],TIME_MINUTES) + ", High: " + High[i]); } //strong sell alert: else if (Signal2=="Strong Sell" && Signal4=="Strong Down" && LastAlert!=2) { if (SendTimeInfoAsTimeLocal) MyTime=TimeLocal(); else if (!SendTimeInfoAsTimeLocal) MyTime=TimeCurrent(); Msg=Subj + " (Trend: "+Signal4+") @ "+DoubleToStr(Close[i],Digits) + ", @ " + TimeToStr(MyTime,TIME_SECONDS); if (Bars>LastAlertBar && i==AlertBar) { LastAlertBar=Bars; if(StrongBuySellAlerts) DoAlerts(Msg,Subj,SoundAlertFileShort); } LastAlert=2; //Last trend Alert was Down Trend Buy Alert if (Show_SignalArrows)//SELL { CreateText(prefix+"En"+(string)SigCounter,0," S",10,"Arial Bold",SellArrowColor,Time[i],High[i]+SignalArrowSpacer(),false); SigCounter++; } //Print("Text: " + TimeToStr(Time[i],TIME_MINUTES) + ", High: " + High[i]); } //else if ((LastAlert==1 || LastAlert==2) && Signal2=="Caution !") //overbought/oversold alert: else if ((LastAlert==1 || LastAlert==2) && (Signal2=="Caution - Overbought !" || Signal2=="Caution - Oversold !")) { Subj=Symbol()+ ", " + TF2Str(Period()) +". Trend "+Signal2;//+". Trend Caution Alert!"; if (LastAlert==2) Subj=Symbol()+ ", " + TF2Str(Period()) +". Trend "+Signal2;//+". Trend Caution Alert!"; //---- if (SendTimeInfoAsTimeLocal) MyTime=TimeLocal(); else if (!SendTimeInfoAsTimeLocal) MyTime=TimeCurrent(); Msg=Subj + " @ "+DoubleToStr(Close[i],Digits) + ", @ " + TimeToStr(MyTime,TIME_SECONDS); if (Bars>LastAlertBar && i==AlertBar) { LastAlertBar=Bars; if (CautionAlerts) DoAlerts(Msg,Subj,SoundAlertFileCautionAlert); } if (Show_SignalArrows) { if (LastAlert==1)//BUY { CreateText(prefix+"En"+(string)SigCounter,0,"*",25,"Arial Bold",StrongBuyArrowCautionColor,Time[i],High[i]+SignalArrowSpacer(),false); SigCounter++; } else//SELL { CreateText(prefix+"En"+(string)SigCounter,0,"*",25,"Arial Bold",StrongSellArrowCautionColor,Time[i],Low[i]-SignalArrowSpacer(),false); SigCounter++; } } LastAlert=3; //Last trend Alert was Down Trend Buy Alert } // End old Alerts //addition: new Alerts: // //medium/weak alerts: else if ((Signal2=="Medium Buy" || Signal2=="Weak Buy") && Signal4=="Weak Up" && LastAlert!=4) { if (SendTimeInfoAsTimeLocal) MyTime=TimeLocal(); else if (!SendTimeInfoAsTimeLocal) MyTime=TimeCurrent(); Msg=Subj + " (Trend: "+Signal4+") @ "+DoubleToStr(Close[i],Digits) + ", @ " + TimeToStr(MyTime,TIME_SECONDS); if (Bars>LastAlertBar && i==AlertBar) { LastAlertBar=Bars; if (MediumWeakBuySellAlerts) DoAlerts(Msg,Subj,SoundAlertFileLong); } LastAlert=4; //Last trend Alert was weak up trend weak buy Alert } else if ((Signal2=="Medium Sell" || Signal2=="Weak Sell") && Signal4=="Weak Down" && LastAlert!=5) { if (SendTimeInfoAsTimeLocal) MyTime=TimeLocal(); else if (!SendTimeInfoAsTimeLocal) MyTime=TimeCurrent(); Msg=Subj + " (Trend: "+Signal4+") @ "+DoubleToStr(Close[i],Digits) + ", @ " + TimeToStr(MyTime,TIME_SECONDS); if (Bars>LastAlertBar && i==AlertBar) { LastAlertBar=Bars; if (MediumWeakBuySellAlerts) DoAlerts(Msg,Subj,SoundAlertFileShort); } LastAlert=5; //Last trend Alert was weak down trend weak down Alert } //consolidation alerts: else if ( (Signal2=="Caution - Overbought !" || Signal2=="Caution - Oversold !") && Signal4=="Consolidation" && LastAlert!=6) { if (SendTimeInfoAsTimeLocal) MyTime=TimeLocal(); else if (!SendTimeInfoAsTimeLocal) MyTime=TimeCurrent(); Msg=Subj + " (Trend: "+Signal4+") @ "+DoubleToStr(Close[i],Digits) + ", @ " + TimeToStr(MyTime,TIME_SECONDS); if (Bars>LastAlertBar && i==AlertBar) { LastAlertBar=Bars; if (CautionAlerts) DoAlerts(Msg,Subj,SoundAlertFileCautionAlert); } LastAlert=6; //Last trend Alert was weak down trend weak down Alert } //end addition: new Alerts // }//if(Show_TrendVisuals) //End If Show Trend Visuals ///////////////////////// }//for(i=limit-1;i>=0;i--) //End For Loop if(Show_TrendVisuals) { for(int i=1;i<=12;i++) //Create the Visuals { switch(i) { /* old: case 1 : CreateLabel(prefix+"SIG"+i,Win,Signal,25,"Wingdings",TDI_col,1,80+SHIFT_Sideway,20+SHIFT_Up_Down); break; case 2 : CreateLabel(prefix+"SIG"+i,Win," @ "+DoubleToStr(BidCur,Digits),13,"Tahoma Narrow",TDI_col,1,125+SHIFT_Sideway,32+SHIFT_Up_Down); break; case 3 : CreateLabel(prefix+"SIG"+i,Win,Signal2,15,"Tahoma Narrow",TDI_col,1,120+SHIFT_Sideway,10+SHIFT_Up_Down); break; case 4 : CreateLabel(prefix+"SIG"+i,Win,"TDI Trend",15,"Tahoma Narrow",TDI_col2,1,120+SHIFT_Sideway,60+SHIFT_Up_Down); break; case 5 : CreateLabel(prefix+"SIG"+i,Win,Signal3,25,"Wingdings",TDI_col2,1,80+SHIFT_Sideway,60+SHIFT_Up_Down); break; case 6 : CreateLabel(prefix+"SIG"+i,Win,Signal4,15,"Tahoma Narrow",TDI_col2,1,115+SHIFT_Sideway,82+SHIFT_Up_Down); break; case 7 : CreateText(prefix+"SIG"+i,Win," 68 ",7,"Tahoma Narrow",CadetBlue,TimeCur,70,true); break; case 8 : CreateText(prefix+"SIG"+i,Win," 50 ",7,"Tahoma Narrow",CadetBlue,TimeCur,52,true); break; case 9 : CreateText(prefix+"SIG"+i,Win," 32 ",7,"Tahoma Narrow",CadetBlue,TimeCur,34,true); break; case 10: Createline(prefix+"UPPERLINE", Win, 68, 68,DarkSlateGray); break; case 11: Createline(prefix+"LOWERLINE", Win, 50, 50,DarkSlateGray); break; case 12: Createline(prefix+"MEDLINE", Win, 32, 32,DarkSlateGray); break; */ case 1 : CreateLabel(prefix+"SIG"+(string)i,Win,Signal,TrendArrowFontSize,"Wingdings",TDI_col,1,80+SHIFT_Sideway,20+SHIFT_Up_Down); break;//red arrow case 2 : CreateLabel(prefix+"SIG"+(string)i,Win," @ "+DoubleToStr(BidCur,Digits),TrendPriceFontSize,TypeFace,TDI_col,1,125+SHIFT_Sideway,32+SHIFT_Up_Down); break;//price case 3 : CreateLabel(prefix+"SIG"+(string)i,Win,Signal2,TrendSignalsFontSize,TypeFace,TDI_col,1,120+SHIFT_Sideway,10+SHIFT_Up_Down); break;//sell trend signals case 4 : CreateLabel(prefix+"SIG"+(string)i,Win,"TDI Trend",TrendSignalsFontSize,TypeFace,TDI_col2,1,120+SHIFT_Sideway,60+SHIFT_Up_Down); break;//tdi-trend writing case 5 : CreateLabel(prefix+"SIG"+(string)i,Win,Signal3,TrendArrowFontSize,"Wingdings",TDI_col2,1,80+SHIFT_Sideway,60+SHIFT_Up_Down); break;//green arrow case 6 : CreateLabel(prefix+"SIG"+(string)i,Win,Signal4,TrendSignalsFontSize,TypeFace,TDI_col2,1,115+SHIFT_Sideway,82+SHIFT_Up_Down); break;//buy trend signals //indicator levels: //case 7 : CreateText(prefix+"SIG"+i,Win," "+RSI_OverboughtLevel+" ",7,TypeFace,CadetBlue,TimeCur,70,true); break; case 7 : CreateText(prefix+"SIG"+(string)i,Win," "+(string)RSI_OverboughtLevel+" ",7,TypeFace,CadetBlue,TimeCur,RSI_OverboughtLevel,true); break; //case 8 : CreateText(prefix+"SIG"+i,Win," "+Level2+" ",7,TypeFace,CadetBlue,TimeCur,52,true); break; case 8 : CreateText(prefix+"SIG"+(string)i,Win," "+(string)Level2+" ",7,TypeFace,CadetBlue,TimeCur,Level2,true); break; //case 9 : CreateText(prefix+"SIG"+i,Win," "+RSI_OversoldLevel+" ",7,TypeFace,CadetBlue,TimeCur,34,true); break; case 9 : CreateText(prefix+"SIG"+(string)i,Win," "+(string)RSI_OversoldLevel+" ",7,TypeFace,CadetBlue,TimeCur,RSI_OversoldLevel,true); break; case 10: Createline(prefix+"UPPERLINE", Win, RSI_OverboughtLevel, RSI_OverboughtLevel,DarkSlateGray); break; case 11: Createline(prefix+"LOWERLINE", Win, Level2, Level2,DarkSlateGray); break; case 12: Createline(prefix+"MEDLINE", Win, RSI_OversoldLevel, RSI_OversoldLevel,DarkSlateGray); break; } } }//End if(Show_TrendVisuals) //If the indicator has just been loaded force a redraw as the Visual labels //don't update properly until the first tick after loading. if (InitialLoad) { InitialLoad=false; if (Show_TrendVisuals) WindowRedraw(); } //---- return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Createline(string objName, int Window, double start, double end, color clr) { ObjectDelete(objName); ObjectCreate(objName, OBJ_TREND,Window,0, start, Time[0], end); ObjectSet(objName, OBJPROP_COLOR, clr); ObjectSet(objName, OBJPROP_STYLE, 2); ObjectSet(objName, OBJPROP_RAY, false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CreateLabel(string LblName, int Window, string LblTxt, int FontSz, string FontName, color FontColor, int Corner, int xPos, int yPos) { if(ObjectFind(LblName)!=0) ObjectCreate(LblName, OBJ_LABEL, Window, 0, 0); ObjectSetText(LblName, LblTxt, FontSz, FontName, FontColor); ObjectSet(LblName, OBJPROP_CORNER, Corner); ObjectSet(LblName, OBJPROP_XDISTANCE, xPos); ObjectSet(LblName, OBJPROP_YDISTANCE, yPos); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CreateText(string TextName, int Window, string LabelText, int FontSz, string FontName, color TextColor, datetime Time1, double Price1, bool del) { if (del) ObjectDelete(TextName); if(ObjectFind(TextName)!=0) { ObjectCreate(TextName, OBJ_TEXT, Window, Time1, Price1); ObjectSetText(TextName, LabelText, FontSz, FontName, TextColor); } else ObjectMove(TextName, 0, Time1, Price1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double StDev(double& Data[], int Per) { return(MathSqrt(Variance(Data,Per))); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double Variance(double& Data[], int Per) { double sum=0, ssum=0; for(int i=0; i