NexusFi: Find Your Edge


Home Menu

 





Stochs on the chart vs as lower study


Discussion in TradeStation

Updated
    1. trending_up 1,059 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 0 posts
    2. attach_file 1 attachments




 
Search this Thread

Stochs on the chart vs as lower study

  #1 (permalink)
 trendfriendpa 
philadelphia USA
 
Experience: Intermediate
Platform: TOS, Webull, Ninja 8
Broker: TD Ameritrade
Trading: options, ES/NQ futures, stocks
Posts: 79 since May 2011
Thanks Given: 54
Thanks Received: 53

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

Attached Thumbnails
Click image for larger version

Name:	stochs on chart.jpg
Views:	166
Size:	40.3 KB
ID:	203310  
Started this thread Reply With Quote




Last Updated on February 27, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts