// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("PrctclModeDComp---TF=5Mnt"); TN=TimeNum(); EntryTime=TN>=103001 && TN<=150000; ExitTime=TN>=151900; PI = 3.1415926; SetBarsRequired( sbrAll,0 ); function MulTwinLevel( Feed, N, c0, c1, b0, b1, b2, a1, a2 ) { Extract = Feed; // initialize for N first bars for( i = Max( N, 2 ); i < BarCount; i++ ) { Extract[ i ] = c0[ i ] * ( b0 * Feed[ i ] + b1 * Feed[ i - 1 ] + b2 * Feed[ i - 2 ] ) + a1 * Extract[ i - 1 ] + a2 * Extract[ i - 2 ] - c1 * Feed[ i - N ]; } return Extract; } function ExtractFilter( Feed, Period, delta ) { N = 0; an = 2 * PI / Period; c0 = b0 = 1; c1 = b1 = b2 = a1 = a2 = gamma1 = 0; beta1 = cos( 2 * PI / Period ); gamma1 = 1 / cos( 4 * PI * delta / Period ); alpha = gamma1 - sqrt( gamma1 ^ 2 - 1 ); a1 = beta1 * ( 1 + alpha ); a2 = - alpha; c0 = ( 1 - alpha ) / 2; b2 = -1; return MulTwinLevel( Feed, N, c0, c1, b0, b1, b2, a1, a2 ); } Period =Optimize("Period", 10, 10, 900, 10 ); Delta =Optimize("Delta", 0.15, 0.05, 1, 0.05 ); Cycle = ExtractFilter( (H+L)/2, Period, Delta ); Trend = MA( Cycle, 2 * Period ); CycleMean=(HHV(Cycle,300)+LLV(Cycle,300))/2; Plot( CycleMean, "CycleMean", colorRed ); Plot( Trend, "Trend", colorBlue ); Buy1=Trend>CycleMean && C>WMA(C,Period) && StochD(14)<23; Short1=Trend<-CycleMean && C77; Buy=Ref(Buy1,-1) && EntryTime; Short=Ref(Short1,-1) && EntryTime; Sell=Short1 OR ExitTime ; Cover=Buy1 OR ExitTime; Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short); BuyPrice=O; ShortPrice=O; SellPrice=C; CoverPrice=C; PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,BuyPrice); PlotShapes(IIf(Sell,shapedownArrow,shapeNone),colorRed,0,sellPrice); PlotShapes(IIf(Short,shapedownArrow,shapeNone),colorYellow,0,shortPrice); PlotShapes(IIf(Cover,shapeUpArrow,shapeNone),colorTurquoise,0,coverPrice); _SECTION_END(); Title = EncodeColor(colorPink)+ Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) + " - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+ "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n";