Sunday, July 17, 2011

Thinkorswim script

https://www.thinkorswim.com/tos/thinkScriptHelp.jsp?laf=bright

http://tda.thinkorswim.com/manual/dark/thinkscript/index.html

http://freethinkscript.blogspot.com/

http://thinkscript.blogspot.com/2007/12/heres-simple-script-to-see-vwap-volume.html

Code example:


declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;

def fastAvg = sum(volume * close, fastLength) / sum(volume, fastLength);
def slowAvg = sum(volume * close, slowLength) / sum(volume, slowLength);
plot Value = fastAvg - slowAvg;
plot Avg = ExpAverage(Value, MACDLength);
plot Diff = Value - avg;
plot ZeroLine = 0;

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if diff >= 0 then if diff > diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if diff < diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));

No comments:

Post a Comment