Stochs on the chart vs as lower study 
February 27th, 2016, 08:26 AM  #1 (permalink) 
Elite Member
philadelphia USA
Futures Experience: Intermediate
Platform: TOS, Sierra Chart
Broker/Data: TD Ameritrade, Infinity Futures
Favorite Futures: options, Russell emini futures
Posts: 73 since May 2011
Thanks: 50 given,
54
received

Stochs on the chart vs as lower study
Thanks to whomever will code this for TS
# = code not being used but in script or a comment # study includes color candle changes based on overbought/oversold condition of 3X declare upper; input K_period = 16; input D_period = 6; input SlowTrendLength = 3; input smoothing_type = { default EMA, SMA, WMA }; input stochastic_type = { FAST, default SLOW }; input over_bought = 75; input over_sold = 25; input show_bubbles = yes; input show_sec_bbls = no; input show_alerts = yes; def aggPer = getAggregationPeriod(); def adjAggPer = if aggPer == AggregationPeriod.MIN then AggregationPeriod.THREE_MIN else if aggPer == AggregationPeriod.TWO_MIN then AggregationPeriod.FIVE_MIN else if aggPer == AggregationPeriod.THREE_MIN then AggregationPeriod.TEN_MIN else if aggPer == AggregationPeriod.FOUR_MIN then AggregationPeriod.TEN_MIN else if aggPer == AggregationPeriod.FIVE_MIN then AggregationPeriod.FIFTEEN_MIN else if aggPer == AggregationPeriod.TEN_MIN then AggregationPeriod.THIRTY_MIN else if aggPer == AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.HOUR else if aggPer == AggregationPeriod.TWENTY_MIN then AggregationPeriod.HOUR else if aggPer == AggregationPeriod.THIRTY_MIN then AggregationPeriod.TWO_HOURS else if aggPer == AggregationPeriod.HOUR then AggregationPeriod.FOUR_HOURS else if aggPer == AggregationPeriod.TWO_HOURS then AggregationPeriod.DAY else if aggPer == AggregationPeriod.FOUR_HOURS then AggregationPeriod.DAY else if aggPer == AggregationPeriod.DAY then AggregationPeriod.THREE_DAYS else if aggPer == AggregationPeriod.TWO_DAYS then AggregationPeriod.WEEK else if aggPer == AggregationPeriod.THREE_DAYS then AggregationPeriod.WEEK else if aggPer == AggregationPeriod.FOUR_DAYS then AggregationPeriod.MONTH else if aggPer == AggregationPeriod.WEEK then AggregationPeriod.MONTH else if aggPer == AggregationPeriod.MONTH then AggregationPeriod.MONTH else Double.NaN; def _kPeriod; def _dPeriod; def _slowTrendLength; if aggPer == AggregationPeriod.MONTH then { _kPeriod = K_period * 3; _dPeriod = D_period * 3; _slowTrendLength = SlowTrendLength * 3; } else { _kPeriod = K_period; _dPeriod = D_period; _slowTrendLength = SlowTrendLength; } def priceH = high( period = adjAggPer ); def priceL = low( period = adjAggPer ); def priceC = close( period = adjAggPer ); def lowest_low = lowest( low, _kPeriod ); def highest_high = highest( high, _kPeriod ); def fastK = if ( highest_high  lowest_low ) <= 0 then 0 else 100 * ( close  lowest_low ) / ( highest_high  lowest_low ); def fastD = if smoothing_type == smoothing_type.EMA then ExpAverage( fastK, _dPeriod ) else Average( fastK, _dPeriod ); def slowK = fastD; def slowD = if smoothing_type == smoothing_type.EMA then ExpAverage( slowK, _dPeriod ) else Average( slowK, _dPeriod ); #Stochastic plot stochD = if stochastic_type == stochastic_type.FAST then fastD else slowD; stochD.HideBubble(); stochD.HideTitle(); stochD.SetPaintingStrategy( PaintingStrategy.POINTS ); stochD.AssignValueColor( if stochD >= stochD[1] then Color.blue else if stochD < stochD[1] then Color.Magenta else Color.GRAY ); #Reference lines plot OverBought = over_bought; OverBought.HideBubble(); OverBought.HideTitle(); OverBought.SetDefaultColor( Color.BLACK ); def Hundred = 100; AddCloud( OverBought, Hundred, Color.RED, Color.RED ); plot OverSold = over_sold; OverSold.HideBubble(); OverSold.HideTitle(); OverSold.SetDefaultColor( Color.BLACK ); def Zero = 0; AddCloud( OverSold, Zero, Color.Yellow, Color.Yellow ); # Plot Arrows on the 50 line # Marks Green Dot only if period previous to Green Dot was below 25 # Marks Red Dot only if period previous to Red Dot was above 75 def MoveUp = stochD[1] <25 and stochD > stochD[1] and stochD[1] < stochD[2]; def MoveDown = stochD[1] > 75 and stochD < stochD[1] and stochD[1] > stochD[2]; #plot ArrowUp = if MoveUp then 50 else double.nan; #ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP); #ArrowUp.SetDefaultColor(Color.LIGHT_ORANGE); #ArrowUP.SetLineWeight(2); #ArrowUp.HideBubble(); #ArrowUp.HideTitle(); #plot ArrowDn = if MoveDown then 50 else double.nan; #ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); #ArrowDn.SetDefaultColor(Color.MAGENTA); #ArrowDn.SetLineWeight(2); #ArrowDn.HideBubble(); #ArrowDn.HideTitle(); # AddLabel to show the value of the Exponential Average # AddLabel(yes, AsText(expAvg1, NumberFormat.TWO_DECIMAL_PLACES), Color.PLUM); # Changes color of Candles AssignPriceColor(if slowK > 75 then Color.BLUE else if slowK < 25 then color.magenta else color.current); If prefer not to post eld file, please PM the eld file to me. Thanks 