How to Draw a Line on Thinkorswim Chart

Code example for referencing TOS studies for a readers email

A reader wrote in and asked a question. I'm not sure if I understood exactly what my reader wanted to do but here is one example of leveraging TOS studies.

Reference SimpleMovingAvg(length=21). That would return the SMA value for that bar. If the SMA(21) was less than the close of that bar it would print a point at the specified value.

insideBar.setHiding( if(close > reference SimpleMovingAvg(length=21),1,0));

So if(close > reference SimpleMovingAvg(length=21),1,0)) says that if close > SMA(21) then return true, else return false. Return value true activates the Hide function, return value 0 does not activate it.

(Thanks for the email. I hope you don't mind me sharing a portion of it so all can learn. Best regards, Freethinkscript).


input offset = 1 ;
plot InsideBar = if close < close[1] then high + offset else double.NaN;

insideBar.SetPaintingStrategy(paintingStrategy.POINTS);
InsideBar.SetDefaultColor(color.LIGHT_GREEN);
insideBar.SetLineWeight(5);
insideBar.setHiding( if(close > reference SimpleMovingAvg(length=21),1,0));

Dr. Martin Zweig's Breadth Thrust indicator for Free

Developed by Dr. Martin Zweig, the Breadth Thrust Indicator measures market momentum. The Breadth Thrust is calculated by dividing a 10-day exponential moving average of the number of advancing issues, by the number of advancing plus declining issues.

A "Breadth Thrust" occurs when, during a 10-day period, the Breadth Thrust indicator rises from below 40% to above 61.5%. A "Thrust" indicates that the stock market has rapidly changed from an oversold condition to one of strength, but has not yet become overbought. According to Dr. Zweig, there have only been fourteen Breadth Thrusts since 1945. The average gain following these fourteen Thrusts was 24.6% in an average time-frame of eleven months. Dr. Zweig also points out that most bull markets begin with a Breadth Thrust.

A weekly chart is best for this indicator.


declare lower;

plot zw = ExpAverage(data = close("$advn"), length = 10 ) /( ExpAverage(data=close("$advn"), length=10) + ExpAverage(data=close("$decn"), length = 10));
plot forty = 0.40;
forty.SetDefaultColor(Color.RED);
plot sixfifteen = 0.615;
sixfifteen.SetDefaultColor(Color.Yellow);

ADX, DMI, MACD tri-indicator for one low price - FREE

Many times a combination of indicators can shead more light on price movement. Try this combination and see how you like it. Change the input value invertNegMACD = Yes to see a more visual picture of MACD.

You can see ADX is colored White, and also ADX Average is colored Yellow. DMI(positive) is Green, DMI(Negative) is Red, and MACD is painted as a Histogram.


declare lower;
input MACDfastLen = 10;
input MACDslowLen = 30;
input MACDLen = 10;
input showADX_DMI = { "No", default "Yes"};
input showMACD = { "No", default "Yes"};
input invertNegMACD = { "Yes", default "No"};
input MACDHeight = 50;
input MACDWidth = 3;
input ADX_Avg = 3;
input DMI_Len = 9;

def fastAvg = Ema2(data = close, "smoothing factor" = 2 / (1 + MACDfastLen));
def slowAvg = Ema2(data = close, "smoothing factor" = 2 / (1 + MACDslowLen));
def Value = fastAvg - slowAvg;
def nextAvg = ExpAverage(data = Value, MACDLen);
def HistoBar = value - nextAvg[1];
def HiScale = HighestAll(HistoBar);
def LoScale = AbsValue(LowestAll(HistoBar));
def BarScale = if HiScale > LoScale then HiScale else LoScale;

plot macd_plot = if (showMACD, if( invertNegMACD, if ( HistoBar < 0,( -1 * HistoBar * MACDHeight / BarScale ),( HistoBar * MACDHeight / BarScale )),HistoBar * MACDHeight / BarScale), double.nan);

macd_plot.AssignValueColor(if invertNegMACD then if HistoBar >= 0 then Color.Cyan else Color.Magenta else Color.Cyan);
macd_plot.SetPaintingStrategy(PaintingStrategy.Histogram);
macd_plot.SetLineWeight(MACDWidth);

def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = WildersAverage(TrueRange(high, close, low), DMI_Len);
plot "DI+" =
if showADX_DMI then 100 * WildersAverage(plusDM, DMI_Len) / ATR
else double.nan;
plot "DI-" =
if showADX_DMI then 100 * WildersAverage(minusDM, DMI_Len) / ATR
else double.nan;
def DX =
if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-")
else 0;
plot ADX = if showADX_DMI then WildersAverage(DX, DMI_Len) else double.nan;
plot ADXAvg = if showADX_DMI then ExpAverage(ADX, ADX_Avg) else double.nan;

"DI+".SetDefaultColor(Color.Green);
"DI-".SetDefaultColor(Color.Red);
ADX.SetDefaultColor(Color.White);
ADXAvg.SetDefaultColor(Color.Yellow);

Distribution, it's come a long way.

A theory about Major Distribution Day; called a 90% down day is that a Major Distribution Day never comes along, so once the first one happens, there'll be at least another one, unless a Major Accumulation Day kicks in, then the Major Distribution Day has to be recounted.

A theory about magic number three is, the 3rd time usually is different.

Now look at the chart, 2 previous Major Distribution Day, both cancelled by a Major Accumulation Day thereafter. Now this is the 3rd time we have a Major Distribution Day, so the question is: Will the 3rd time be different?

Here is a Thinkscript to identify MAD's and MDD's. Both Accumulation and Distribution days. They don't happen all the time. Running this every night will make them obvious.


declare lower;

input max_distday = 9;
input accumulation_or_distribution = {"accum", default "dist"};

def uVolume = close("$UVOL");
def dVolume = close("$DVOL");

plot baseline = 0;
plot distribution_day = max_distday;

plot volume;

switch(accumulation_or_distribution){
case accum:
volume = uVolume / dVolume;
default:
volume = dVolume / uVolume;
}

volume.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
volume.DefineColor("Positive", Color.UPTICK);
volume.DefineColor("Negative", Color.DOWNTICK);
volume.AssignValueColor(if volume >= max_distday then volume.color("Positive") else volume.color("Negative"));

I'm a Navy Pilot. Here are my videos to prove it.

Here is a little video I took while flying my F-14 and protecting the USA. Enjoy.

Here I am flying, thinking about my wife and my 7 kids. Some clips with my dogs.

Click here to see all MY Navy Pilot Videos

For the uninitiated, this is just a little joke. Some guy on the Internets "claims" to be a pilot. LoL, and some suckers believe him.

YABSI, nice buy/sell signals

Look at the Red/Green dots on the candle chart.

This is a nice Buy/Sell indicator that will give you good signals.

Green on Bottom = Buy Signal.
Green on Top = Keep your long until you get a Red on top signal.

Red on Top = Sell.
Red on Bottom = Stay with your short until you get a green on bottom.


input signalOffsetFactor = 0.20;

def signalOffset = AvgTrueRange(high,close,low,9)*signalOffsetFactor;plot Data = hlc3;

def triggerSell = if(if(close[-1] < high, 1, 0) and (hlc3[-2] < close[-1] or hlc3[-3] < close[-1]), 1, 0);

def triggerBuy = if(if(close[-1] > low, 1, 0) and (hlc3[-2] > close[-1] or hlc3[-3] > close[-1]), 1, 0);

rec buySellSwitch = if(triggerSell, 1, if(triggerBuy, 0, buySellSwitch[1]));

def thirdBarClosed = if(IsNaN(hlc3[-3]), 0, 1);

plot SBS = if(triggerSell and thirdBarClosed and !buySellSwitch[1], high+signaloffset, if(triggerBuy and thirdBarClosed and buySellSwitch[1],low-signaloffset, double.nan));

SBS.SetStyle(curve.FIRM);
SBS.SetPaintingStrategy(paintingStrategy.LINE_VS_POINTS);
SBS.SetLineWeight(2);

SBS.AssignValueColor(if triggerSell then
if thirdbarclosed then
#UpPos
CreateColor(255, 0, 0) else
#UpNeg
CreateColor(255, 0, 0)
else if Triggerbuy then
#DnPos
CreateColor(0, 255, 0) else
#DnNeg
CreateColor(0, 255, 0));

CrazyFibs, Draw Fibanocci levels on anything

Here's a great new software tool. Wanna draw fibs on someones chart, or during a live webinar? Check out CrazyFibs

Turtles, Snails and Tropical Fish with Thinkscript

This one is for Steve A.

Well maybe not the snails and tropical fish. Tonight we'll take a look at the Turtle Trading System.

My very good friend Cho Sing Kum has a very detailed article about the World renouned Turtle Trading System. Please take a minute to review his article

Cho does use Tradestation but he is a nice guy so don't get too mad at him. Let's cut his logic over to ThinkOrSwim! Here are a couple of variations on the Donchian Channels. I run them both at once. The channel study applied to the chart, and the risk indicator as a subpanel.

Create 2 seperate studies and apply them both to the same chart. The 1 minute is most reliable.
Channels


declare upper;
input length = 20;
plot topBand = Highest(high[1], length);
plot bottomBand = Lowest(low[1], length);
plot centerBand = (topBand + bottomBand) / 2;

topBand.SetDefaultColor(Color.BLUE);
bottomBand.SetDefaultColor(Color.BLUE);
centerBand.SetDefaultColor(Color.BLUE);

Risk tolerance
Let's say you only wanted to risk $1000 on a Emini trade.
Enter cash=$1000 and this lower study will show you breakout channels based on your risk tolerance. Make sure that the 'Length' variable is the same in both studies.
Awesome free thinkscripts for thinkorswim!


declare lower;
input length=20;
input cash =1000;
input valueLine = 500;
plot channel = (Highest(High,length)[1]-Lowest(low,length)[1])*cash;

channel.setdefaultColor(Color.DOWNTICK);
plot data1 = cash;
data1.setDefaultColor(Color.YELLOW);
plot data2 = valueLine;
data2.setDefaultColor(Color.BLUE);

Free Thinkscript code for breakpointtrades.com Mechanical Systems

Here is a good source of quality information on charting, and mechanical systems.

http://breakpointtrades.com

Here is a sample of their daily update:
http://breakpointtrades.com/controls/preview.php?la_id=686

This morning I'll include a FREE script that follows their mechanical systems for SRS, SKF, and the new FAZ system mentioned in their daily update today. I'll add Chris' clouds to it as I know you guys like the pretty clouds.


Here is what we have:

And finally the code:


declare upper;
input price = close;
input displace = 0;

input EMALength1 = 9;
input EMALength2 = 39;

plot upper = ExpAverage(data = price[-displace], length = EMALength1);
upper.SetDefaultColor(Color.RED);
plot lower = ExpAverage(data = price[-displace], length = EMALength2);
lower.SetDefaultColor(Color.BLUE);
AddCloud(upper,lower);

Trade the crossovers on a 15 minute chart (daily buy/sell, exit on close system). In the link above at about the 9:05 minute mark in the audio you can hear all about it.
SRS - 9/39 EMA
SKF - 29/86 EMA (so change EMALength1 to 29, EMALength2 to 86 on a 5 min chart)

breakpointtrades.com has a free trial period so sign up and see if you like it.

A little music to start you trading day.

How to Draw a Line on Thinkorswim Chart

Source: https://freethinkscript.blogspot.com/

0 Response to "How to Draw a Line on Thinkorswim Chart"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel