Stock futures inch higher after another losing week on Wall Street
Is it possible to make a living trading stocks?
Trading can become a full-time career opportunity, a part-time opportunity, or just a way to generate supplemental income.
AMZN
Amazon Stock Split Puts It in Play to Join the Dow
thinkscript
thinkscript
thinkscript
thinkScript
#THE SOFTWARE.
#
script WMA_Smooth {
input price = hl2;
plot smooth = (4 * price
+ 3 * price[1]
+ 2 * price[2]
+ price[3]) / 10;
}
script Phase_Accumulation {
# This is Ehler’s Phase Accumulation code. It has a full cycle delay.
# However, it computes the correction factor to a very high degree.
#
input price = hl2;
rec Smooth;
rec Detrender;
rec Period;
rec Q1;
rec I1;
rec I1p;
rec Q1p;
rec Phase1;
rec Phase;
rec DeltaPhase;
rec DeltaPhase1;
rec InstPeriod1;
rec InstPeriod;
def CorrectionFactor;
if barNumber() <= 5
then {
Period = 0;
Smooth = 0;
Detrender = 0;
CorrectionFactor = 0;
Q1 = 0;
I1 = 0;
Q1p = 0;
I1p = 0;
Phase = 0;
Phase1 = 0;
DeltaPhase1 = 0;
DeltaPhase = 0;
InstPeriod = 0;
InstPeriod1 = 0;
} else {
CorrectionFactor = 0.075 * Period[1] + 0.54;
# Smooth and detrend my smoothed signal:
Smooth = WMA_Smooth(Price);
Detrender = ( 0.0962 * Smooth
+ 0.5769 * Smooth[2]
– 0.5769 * Smooth[4]
– 0.0962 * Smooth[6] ) * CorrectionFactor;
# Compute Quadrature and Phase of Detrended signal:
Q1p = ( 0.0962 * Detrender
+ 0.5769 * Detrender[2]
– 0.5769 * Detrender[4]
– 0.0962 * Detrender[6] ) * CorrectionFactor;
I1p = Detrender[3];
# Smooth out Quadrature and Phase:
I1 = 0.15 * I1p + 0.85 * I1p[1];
Q1 = 0.15 * Q1p + 0.85 * Q1p[1];
# Determine Phase
if I1 != 0 then {
# Normally, ATAN gives results from -pi/2 to pi/2.
# We need to map this to circular coordinates 0 to 2pi
if Q1
>= 0 and I1 > 0 then { # Quarant 1
Phase1 = ATan(absValue(Q1/I1));
} else if Q1 >= 0 and I1 < 0 then { # Quadrant 2
Phase1 = Double.PI – ATan(absValue(Q1/I1));
} else if Q1 < 0 and I1 < 0 then { # Quadrant 3
Phase1 = Double.PI + ATan(absValue(Q1/I1));
} else { # Quadrant 4
Phase1 = 2*Double.PI – ATan(absValue(Q1/I1));
}
} else if Q1 > 0 then { # I1 == 0, Q1 is positive
Phase1 = Double.PI/2;
} else if Q1 < 0 then { # I1 == 0, Q1 is negative
Phase1 = 3*Double.PI/2;
} else { # I1 and Q1 == 0
Phase1 = 0;
}
# Convert phase to degrees
Phase = Phase1 * 180 / Double.PI;
if Phase[1] < 90 and Phase > 270 then {
# This occurs when there is a big jump from 360-0
DeltaPhase1 = 360 + Phase[1] – Phase;
} else {
DeltaPhase1 = Phase[1] – Phase;
}
# Limit our delta phases between 7 and 60
if DeltaPhase1 < 7
then {
DeltaPhase = 7;
} else if DeltaPhase1 > 60 then {
DeltaPhase = 60;
} else {
DeltaPhase = DeltaPhase1;
}
# Determine Instantaneous period:
InstPeriod1 =
-1*(fold i=0 to 40 with v=0 do
if v < 0 then
v
else if v > 360 then
-i
else
v + getValue(DeltaPhase, i, 41)
);
if InstPeriod1 <= 0 then {
InstPeriod = InstPeriod[1];
} else {
InstPeriod = InstPeriod1;
}
Period = 0.25*InstPeriod + 0.75*Period[1];
}
plot DC = period;
}
script Ehler_MAMA {
input price = hl2;
input FastLimit = 0.5;
input SlowLimit = 0.05;
rec Period;
rec Period_raw;
rec Period_cap;
rec Period_lim;
rec Smooth;
rec Detrender;
rec I1;
rec Q1;
rec jI;
rec jQ;
rec I2;
rec Q2;
rec I2_raw;
rec Q2_raw;
rec Phase;
rec DeltaPhase;
rec DeltaPhase_raw;
rec alpha;
rec alpha_raw;
rec Re;
rec Im;
rec Re_raw;
rec Im_raw;
rec SmoothPeriod;
rec vmama;
rec vfama;
def CorrectionFactor = Phase_Accumulation(price).CorrectionFactor;
if barNumber() <= 5
then {
Smooth = 0;
Detrender = 0;
Period = 0;
Period_raw = 0;
Period_cap = 0;
Period_lim = 0;
I1 = 0;
Q1 = 0;
I2 = 0;
Q2 = 0;
jI = 0;
jQ = 0;
I2_raw = 0;
Q2_raw = 0;
Re = 0;
Im = 0;
Re_raw = 0;
Im_raw = 0;
SmoothPeriod = 0;
Phase = 0;
DeltaPhase = 0;
DeltaPhase_raw = 0;
alpha = 0;
alpha_raw = 0;
vmama = 0;
vfama = 0;
} else {
# Smooth and detrend my smoothed signal:
Smooth = WMA_Smooth(Price);
Detrender = ( 0.0962 * Smooth
+ 0.5769 * Smooth[2]
– 0.5769 * Smooth[4]
– 0.0962 * Smooth[6] ) * CorrectionFactor;
Q1 = ( 0.0962 * Detrender
+ 0.5769 * Detrender[2]
– 0.5769 * Detrender[4]
– 0.0962 * Detrender[6] ) * CorrectionFactor;
I1 = Detrender[3];
jI = ( 0.0962 * I1
+ 0.5769 * I1[2]
– 0.5769 * I1[4]
– 0.0962 * I1[6] ) * CorrectionFactor;
jQ = ( 0.0962 * Q1
+ 0.5769 * Q1[2]
– 0.5769 * Q1[4]
– 0.0962 * Q1[6] ) * CorrectionFactor;
# This is the complex conjugate
I2_raw = I1 – jQ;
Q2_raw = Q1 + jI;
I2 = 0.2*I2_raw + 0.8*I2_raw[1];
Q2 = 0.2*Q2_raw + 0.8*Q2_raw[1];
Re_raw = I2*I2[1] + Q2*Q2[1];
Im_raw = I2*Q2[1] – Q2*I2[1];
Re = 0.2*Re_raw + 0.8*Re_raw[1];
Im = 0.2*Im_raw + 0.8*Im_raw[1];
# Compute the phase
if Re != 0 and Im != 0 then {
Period_raw = 2*double.PI / atan(Im/Re);
} else {
Period_raw = 0;
}
if Period_raw > 1.5*Period_raw[1] then {
Period_cap = 1.5*Period_raw[1];
} else if Period_raw < 0.67 * Period_raw[1] {
Period_cap = 0.67 * Period_raw[1];
} else {
Period_cap = Period_raw;
}
if Period_cap < 6 then {
Period_lim = 6;
} else if Period_cap > 50 then {
Period_lim = 50;
} else {
Period_lim = Period_cap;
}
Period = 0.2*Period_lim + 0.8*Period_lim[1];
SmoothPeriod = 0.33*Period + 0.67*SmoothPeriod[1];
if I1 != 0 then {
Phase = ATan(Q1 / I1);
} else if Q1 > 0 then { # Quadrant 1:
Phase = Double.Pi/2;
} else if Q1 < 0 then { # Quadrant 4:
Phase = -Double.Pi/2;
} else { # Both numerator and denominator are 0.
Phase = 0;
}
DeltaPhase_raw = Phase[1] – Phase;
If DeltaPhase_raw < 1 then {
DeltaPhase = 1;
} else {
DeltaPhase = DeltaPhase_raw;
}
alpha_raw = FastLimit / DeltaPhase;
If alpha_raw < SlowLimit then {
alpha = SlowLimit;
} else {
alpha = alpha_raw;
}
vmama = alpha*Price + (1 – alpha)*vmama[1];
vfama = 0.5*alpha*vmama + (1 – 0.5*alpha)*vfama[1];
}
plot MAMA = vmama;
plot FAMA = vfama;
}
declare lower;
input price = hl2;
input FastLimit = 0.5;
input SlowLimit = 0.05;
def MAMA = Ehler_MAMA(price, FastLimit, SlowLimit).MAMA;
def FAMA = Ehler_MAMA(price, FastLimit, SlowLimit).FAMA;
Plot MADIFF = (mama-fama);
madiff.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
madiff.AssignValueColor (if madiff >= 0.00 then (color.green) else (color.red));
Plot MALine = madiff;
maline.AssignValueColor (if madiff >= 0.00 then (color.green) else (color.red));
thinkScript
# Dual Moving Averages with clouds and cross arrows
#Labels added by SFL
#TOS Title = CloudBetween2MovingAverages
#hint:Cloud usage between two moving averages
declare upper;
# Input Code
input price = close;#hint close:Select the price of choice
input fastLength = 8;#hint fastLength:The fast average length
input fastAvgType = AverageType.SIMPLE;#hint fastAvgType:Select the average type
input slowLength = 20;#hint slowLength:The slow average length
input slowAvgType = AverageType.SIMPLE; #hint slowAvgType:Select the average type
input Show_Crosses = YES;#hint Show_Crosses:Toggles crossing arrows ON/OFF
# Moving Average Plot Code
plot FastMva = MovingAverage( fastAvgType, price, fastLength );
plot SlowMva = MovingAverage( slowAvgType, price, slowLength );
# Cloud Code
AddCloud( FastMva, SlowMva, Color.YELLOW, Color.RED );
# Crossing Code
def CrossUp = if Crosses(FastMva, SlowMva, CrossingDirection.above) then 1 else 0;
Plot UpArrow = If CrossUp && Show_Crosses then low else double.nan;
UpArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
UpArrow.SetLineWeight(3);
UpArrow.SetDefaultColor(Color.GREEN);
def CrossDown = if Crosses(FastMva, SlowMva, CrossingDirection.below) then 1 else 0;
Plot DownArrow = If CrossDown && Show_Crosses then high else double.nan;
DownArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DownArrow.SetLineWeight(3);
DownArrow.SetDefaultColor(Color.RED);
# Label Code
#AddLabel(Show_Crosses,”Cross = UP ARROW”,color.PINK);
addlabel(1,”Slow MA(” + slowLength + “) is ” + (If fastAvgType == AverageType.EXPONENTIAL then “Exponential average”
else if fastAvgType == AverageType.Hull then “Hull average”
else if fastAvgType == AverageType.simple then “Simple average”
else if fastAvgType == AverageType.wilders then “Wilders average”
else if fastAvgType == AverageType.weighted then “Weighted average”
else “”) ,color.cyan);
addlabel(1,”Fast MA(” + fastLength + “) is ” + (If slowAvgType == AverageType.EXPONENTIAL then “Exponential average”
else if slowAvgType == AverageType.Hull then “Hull average”
else if slowAvgType == AverageType.simple then “Simple average”
else if slowAvgType == AverageType.wilders then “Wilders average”
else if slowAvgType == AverageType.weighted then “Weighted average”
else “”) ,color.pink);
# end
thinkScript
#Start Script#
declare lower;
input show_bubbles= no;
input show_shadow= yes;
input show_ema= no;
input show_historical_chop= yes;
input trade_in_squeeze= yes;
input show_mini_studies= no;
##studies
def value = MACD().”value”;
def avg = MACD().”avg”;
def dmiosc = DMI_Oscillator().”osc”;
def vplus = VortexIndicator().”vi+”;
def vminus = VortexIndicator().”vi-“;
def squeezehist = TTM_Squeeze().”histogram”;
def bbs = BollingerBandsSMA().”upperband”;
def kelt = KeltnerChannels().”upper_band”;
##Normalizers
script normalizePlot {
input data = close;
input newRngMin = 1;
input newRngMax = 20;
input vertdisp= 0;
def hhData = HighestAll( data );
def llData = LowestAll( data );
plot nr = (((newRngMax – newRngMin) * (data – llData)) /
(hhData – llData)) + newRngMin;
}
#mobiuschoppiness
def chopLength = 14;
def chopSignal = 3;
input CIx = {default CIB, CIA};
def CIA = 100 * Log( Sum( TrueRange(high, close, low), chopLength)) / ( Highest(close[1], chopLength) – Lowest(close[1], chopLength)) / Log(chopLength);
def CIB = ((Log(Sum(TrueRange(high, close, low), chopLength) /
(Highest(if high >= close[1] then high else close[1], chopLength) – Lowest( if low <= close[1] then low else close[1], chopLength))) / Log(10)) / (Log(chopLength) / Log(10))) * 100;
def CI = if CIx == CIx.CIB then CIB else CIA;
#Grail
##Grail Inputs
def showlastcrossover = yes;
def lengthW = 2;
def price = close;
def lengthM = 3;
def lengthM2 = 4;
#Grail Calc’s and Cond’s
def coeffW = lengthW * price * price – 2 * price * Sum(price, lengthW)[1] + Sum(price * price, lengthW)[1];
def coeffM = lengthM * price * price – 2 * price * Sum(price, lengthM)[1] + Sum(price * price, lengthM2)[1];
def EhlersWarrow = WildersAverage((Sum(coeffW * price, lengthW) / Sum(coeffW, lengthW)), lengthW);
def EhlersMarrow = WildersAverage((ExpAverage((Sum(coeffM * price, lengthM) / Sum(coeffM, lengthM)), lengthM)), lengthM2);
def conditionBELOW = Crosses(EhlersWarrow, EhlersMarrow, CrossingDirection.BELOW);
def conditionABOVE = Crosses(EhlersWarrow, EhlersMarrow, CrossingDirection.ABOVE);
## Grail Plots
plot down = if conditionBELOW == yes then 21 else Double.NaN;
plot up = if conditionABOVE == yes then 21 else Double.NaN;
down.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
down.AssignValueColor(Color.YELLOW);
down.SetLineWeight(2);
up.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
up.AssignValueColor(Color.YELLOW);
up.SetLineWeight(2);
##modifications
def macdosc = value – avg;
def vortexosc = vplus – vminus;
def squeeze = if bbs < kelt then yes else no;
def volosc = (Average(volume, 12) – Average(volume, 26));
##conditions/plots
plot volume = volosc;
plot volume1 = 21;
plot macd1= if trade_in_squeeze==no and squeeze==yes then double.nan else if macdosc > 0 then 18 else 16;
plot macd2 = if trade_in_squeeze==no and squeeze==yes then double.nan else if macdosc < 0 then 18 else 16;
plot dmi1 = if trade_in_squeeze==no and squeeze==yes then double.nan else if dmiosc > 0 then 14 else 12;
plot dmi2 = if trade_in_squeeze==no and squeeze==yes then double.nan else if dmiosc < 0 then 14 else 12;
plot vortex1 = if trade_in_squeeze==no and squeeze==yes then double.nan else if vortexosc > 0 then 10 else 8;
plot vortex2 = if trade_in_squeeze==no and squeeze==yes then double.nan else if vortexosc <= 0 then 10 else 8;
plot squeezehist1 = if trade_in_squeeze==no and squeeze==yes then double.nan else if squeezehist > 0 then 6 else 4;
plot squeezehist2 = if trade_in_squeeze==no and squeeze==yes then double.nan else if squeezehist < 0 then 6 else 4;
plot insqueeze = if squeeze == yes then yes else 1;
plot chop = if show_historical_chop == yes then 1 else double.nan;
##styling
###Coloring
volume.DefineColor(“Highest”, Color.GREEN);
volume.DefineColor(“Lowest”, Color.LIGHT_RED);
volume.AssignNormGradientColor(9, volume.Color(“Lowest”), volume.Color(“Highest”));
volume.Hide();
volume1.AssignValueColor(volume.TakeValueColor());
volume1.SetLineWeight(5);
macd1.SetDefaultColor(Color.CYAN);
macd2.SetDefaultColor(Color.CYAN);
dmi1.SetDefaultColor(Color.CYAN);
dmi2.SetDefaultColor(Color.CYAN);
vortex1.SetDefaultColor(Color.CYAN);
vortex2.SetDefaultColor(Color.CYAN);
squeezehist1.SetDefaultColor(Color.CYAN);
squeezehist2.SetDefaultColor(Color.CYAN);
insqueeze.AssignValueColor(if squeeze == yes then Color.RED else Color.GREEN);
insqueeze.SetPaintingStrategy(PaintingStrategy.POINTS);
insqueeze.SetLineWeight(5);
AddLabel(1, if CI <= 50 then “Trend Level: Trending” else if CI > 50 and CI <=68.2 then “Trend Level: Choppy” else “Trend Level: Very Choppy”, if CI <= 50 then Color.GREEN else if CI > 50 and CI <=68.2 then Color.YELLOW else Color.RED);
chop.assignValueColor(if ci<=50 then color.dark_green else if ci>50 and ci<68.2 then color.yellow else color.dark_red);
chop.setpaintingstrategy(PaintingStrategy.SQUARED_HISTOGRAM);
###clouds
AddCloud(macd1, macd2, Color.GREEN, Color.RED);
AddCloud(dmi1, dmi2, Color.GREEN, Color.RED);
AddCloud(vortex1, vortex2, Color.GREEN, Color.RED);
AddCloud(squeezehist1, squeezehist2, Color.GREEN, Color.RED);
#special cloud
#AddCloud(macd1, macd2, Color.GREEN, Color.RED);
###chartbubbles
AddChartBubble(BarNumber() % 150 == 0 and show_bubbles==yes, 15, “MACD”, Color.YELLOW);
AddChartBubble(BarNumber() % 150 == 0 and show_bubbles==yes, 11, “DMI”, Color.YELLOW);
AddChartBubble(BarNumber() % 150 == 0 and show_bubbles==yes, 7, “Vortex”, Color.YELLOW);
AddChartBubble(BarNumber() % 150 == 0 and show_bubbles==yes, 3, “Histogram”, Color.YELLOW);
##Signal
def allignedlong = if macd1 == 18 and dmi1 == 14 and vortex1 == 10 and squeezehist1 == 6 then 18 else if show_shadow==yes then 4 else double.nan;
def allignedshort = if macd2 == 18 and dmi2 == 14 and vortex2 == 10 and squeezehist2 == 6 then 18 else if show_shadow == yes then 4 else double.nan;
AddCloud(allignedlong, allignedshort, Color.GREEN, Color.RED);
##T3 EMA Knot
def n = 7;
def n1 = 10;
def n2 = 14;
def n3 = 21;
def vf = 0.7;
def c = rsiwilder();
def a = (Inertia(c, n) * (1 + vf)) –
(Inertia(Inertia(c, n), n) * vf);
def GD = ExpAverage(a, n );
def T1 = ExpAverage(GD, n1);
def T2 = ExpAverage(T1, n2);
def T3 = ExpAverage(T2, n3);
def data = NormalizePlot(GD,1,20);
def data1 = NormalizePlot(t1,1,20);
def data2 = NormalizePlot(t2,1,20);
def data3 = NormalizePlot(t3,1,20);
def knot1= if data>data1 then 1 else -1;
def knot2= if data1>data2 then 1 else -1;
def knot3= if data2>data3 then 1 else -1;
def knot4= if data1>data3 then 1 else -1;
def knot= knot1+knot2+knot3+knot4;
#EMA Plots
plot ema = if show_ema==yes then data else double.nan;
plot ema1 = if show_ema==yes then data1 else Double.NaN;
plot ema2 = if show_ema==yes then data2 else Double.NaN;
plot ema3 = if show_ema==yes then data3 else Double.Nan;
addlabel(1, if between(knot, -1, 1) then “Knot Level: Knotted” else
if between(knot, -2, 2) then “Knot Level: Loose” else if knot>2 then “Knot Level: Long” else “Knot Level: Short”, if between(knot, -1, 1) then color.gray else if knot==2 then color.dark_green else if knot==-2 then color.dark_red else if knot==3 or knot==4 then color.green else color.red);
#addlabel(1, knot, color.white);
#Mini studies
#plot minimacd1= normalizeplot(value,18,16);
#plot minimacd2= normalizeplot(avg,18,16);
plot minimacd= if show_mini_studies==yes then normalizeplot(macdosc * -1,19,15) else double.nan;
plot minidmi= if show_mini_studies==yes then normalizeplot(dmiosc * -1,15,11) else double.nan;
plot minivortex= if show_mini_studies==yes then normalizeplot(vortexosc * -1,11,7) else double.nan;
plot minisqueeze= if show_mini_studies==yes then normalizeplot(squeezehist * -1,7,3) else double.nan;
plot minimacdzero= if show_mini_studies==yes then 17 else double.nan;
plot minidmizero= if show_mini_studies==yes then 13 else double.nan;
plot minivortexzero= if show_mini_studies==yes then 9 else double.nan;
plot minisqueezezero=if show_mini_studies==yes then 5 else double.nan;
#miniplots
minimacd.setdefaultcolor(color.magenta);
minidmi.setdefaultcolor(color.magenta);
minivortex.setdefaultcolor(color.magenta);
minisqueeze.setdefaultcolor(color.magenta);
minimacdzero.setdefaultcolor(color.white);
minidmizero.setdefaultcolor(color.white);
minivortexzero.setdefaultcolor(color.white);
minisqueezezero.setdefaultcolor(color.white);
#End script
thinkScript
declare lower;
input length = 14;
input trendSpeed = 25;
input thresholdLine = 20;
plot Threshold = thresholdLine;
Threshold.setDefaultColor(color.green);
Threshold.setStyle(curve.FIRM);
Threshold.setLineWeight(2);
plot Bullish_Power = DiPlus(length = length);
Bullish_Power.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Bullish_Power.setLineWeight(5);
Bullish_Power.setDefaultColor(color.white);
plot Bearish_Power = DiMinus(length = length);
Bearish_Power.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Bearish_Power.setLineWeight(5);
Bearish_Power.setDefaultColor(color.red);
plot Trend_Speed = ADX(length = length);
Trend_Speed.setDefaultColor(color.yellow);
Trend_Speed.setLineWeight(5);
alert(crosses(Bullish_Power, Bearish_Power, CrossingDirection.ABOVE), “Power Shift Bullish”, Alert.BAR, sound.Ring);
alert(crosses(Bullish_Power, Bearish_Power, CrossingDirection.BELOW), “Power Shift Bearish”, Alert.BAR, sound.Ring);
alert(crosses(Trend_Speed, Threshold, CrossingDirection.ABOVE), “Trending”, Alert.BAR, sound.Ring);
alert(crosses(Trend_Speed, Threshold, CrossingDirection.BELOW), “Choppy”, Alert.BAR, sound.Ring);
# end