/*[[ Name := Trend Trigger Modified Reference := Technical Analysis of Stocks and Commodities, Dec. 2004,p.28. M.H. Pee TTF Author := Paul Y. Shimada Link := PaulYShimada@Y... Notes := Modified version of Trend Trigger Factor by mikesbon (thanks to perkyz) Separate Window := Yes First Color := SkyBlue First Draw Type := Line First Symbol := 217 Use Second Data := Yes Second Color := LightSeaGreen Second Draw Type := Line Second Symbol := 218 ]]*/ Inputs: TTFbars(15), //15=default number of bars for computation t3_period(4), b(0.7), mode_0Sep_1Main(0), //0=Separate window Line (with dual trigger) //1=Main window Histogram (colored bars) barBegin(1000), //<1000 recommended for faster speed //0=All bars computed & plotted show_Info(0), //0=Hide on-chart Info //1=Show on-chart Info & Print Tick Data to Journal //-1=NEVER show ; Variables: //Specific IndicatorName("py.TTF"), Version("S01"), HighestHighRecent(0), HighestHighOlder(0), LowestLowRecent(0), LowestLowOlder(0), BuyPower(0), SellPower(0), TTF(0), ; Variable : t3(0); Variable : e1(0),e2(0),e3(0),e4(0),e5(0),e6(0),c1(0),c2(0),c3(0),c4(0); Variable : r(0),w1(0),w2(0),b2(0),b3(0); Variables: //Generic, mostly for module flow control shift(0), count(0), is_First(True), loopBegin(0), prevBars(0), PrevTime(0), tick(0), prevShift(99999), badPlotBars(0),//Discarded first (old) bars with bad computed values firstPlotBar(0), CheckSum(0), CheckSumPrev(0), Msg(""), ; b2=b*b; b3=b2*b; c1=-b3; c2=(3*(b2+b3)); c3=-3*(2*b2+b+b3); c4=(1+3*b+b3+3*b2); r=t3_period; if r<1 then r=1; r = 1 + 0.5*(r-1); w1 = 2 / (r + 1); w2 = 1 - w1; /*======================*/ /* Begin Pre-Loop Setup */ /*======================*/ //Check for additional bars loading or total reloadng. If Bars1 Then is_First=True; prevbars=Bars; //Have any Inputs changed? CheckSum=TTFbars+mode_0Sep_1Main+barBegin+show_Info; If CheckSum!=CheckSumPrev Then is_First=True; CheckSumPrev=CheckSum; //-------------------------------------------------------------------- If is_First Then { /* This block executes ONLY First Time for each Attachment-To-Chart. If MT is closed or another Profile is selected, the values & parameters for this module are saved, and when MT or this Profile is restarted, it would not be the First Time Attachment-To-Chart. So this block would not execute unless the value of "Bars" has changed. */ SetLoopCount(0); /*==============*/ /* Check Inputs */ /*==============*/ If 0>TTFbars or TTFbars>299 Then { Msg=IndicatorName+" **Input Error** :" +" TTFbars must be between 0 and 300. Cannot="+TTFbars; Exit; }; If mode_0Sep_1Main<>0 and mode_0Sep_1Main<>1 Then { Msg=IndicatorName+" **Input Error** : " +" and mode_0Sep_1Main must be {0,1}. Cannot="+mode_0Sep_1Main; Alert(Msg); Exit; }; //Comment to display IndicatorName & parameters Msg=IndicatorName+".v"+Version+"("+TTFbars+")"; Print(Msg); If show_Info!=-1 Then Comment(Msg); //Usage if show_Info==1 Then Comment(Msg +" Trend Trigger Factor (TTF)" +"\n User-Inputs:" +"\nTTFbars:" +"\n 15=default Number of bars for computation." +"\nmode_0Sep_1Main:" +"\n 0=Separate window Line with dual trigger" +"\n TTF>+100=Long" +"\n TTF<-100=Short" +"\n Else=Ranging" +"\n 1=Main window Histogram with colored bars" +"\nbarBegin:" +"\n <1000 recommended for faster computation" +"\n 0=All bars computed & plotted (slower)" +"\nshow_Info:" +"\n 0=Hide on-chart Info" +"\n 1=Show on-chart Info & Print Tick data to Journal" +"\n -1=Never show Comments" ); If barBegin>0 and barBegin=0 Then SetIndexValue2(shift,100) Else SetIndexValue2(shift,-100); Case 1: //Main Window Colored Bars If TTF>=100 Then //Bull Trend, Blue bars { SetIndexValue(shift,High[shift]); SetIndexValue2(shift,Low[shift]); } Else If TTF<=-100 Then //Bear Trend, Red bars { SetIndexValue(shift,Low[shift]); SetIndexValue2(shift,High[shift]); } Else //No Trend, No colored bars { SetIndexValue(shift,0); SetIndexValue2(shift,0); } };//If TTF>=100 Then ... Else };//Switch mode_0Sep_1Main loopBegin=loopBegin-1; }