Needs help with Coding Custom Indicators for Swing Trading

M

Montana101x

New member
Hi alllll, I am new here and thinkorswim user particularly on demo lol...I know but take it easy on me and I am on process of learning and growing. My goal is to become a Pro Swing Trader particularly on mid or small good Caps. I found quite few indicators on site while researching but they are customized for other platforms.

I found so many awesome indicators but only have their images. There’s one indicator and I hope someone can code this it would be awesome. It’s MACD with SMA and works awesome for swing trading... find attached blew and let help each other....


Please kindly code her and share with us. Soon I’ll share more awesome indicators for coding and thanks


 
Last edited:
mc01439

mc01439

Active member
VIP
Warehouse
Think this is what you ask for. I am not an expert coder but this should do.[upl-image-preview





You will need to decide when to exit and what STOPS to use.

Strategy
Rich (BB code):
input tradesize = 1;

input price = close;

#MACD

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

plot Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
plot UpSignal = if Diff crosses above 0 then 0 else Double.NaN;
plot DownSignal = if Diff crosses below 0 then 0 else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Diff.SetDefaultColor(GetColor(5));
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"));

#SMA
input lengthema = 34;

def AvgSMA = SimpleMovingAvg(Diff, lengthema);

#Orders
def bull = Diff crosses above AvgSMA;

def bear = Diff crosses below AvgSMA;

#Orders
AddOrder(OrderType.BUY_AUTO, bull, close, tradeSize, Color.ORANGE, Color.ORANGE, "MACD SMA buy @ " + close);

AddOrder(OrderType.SELL_AUTO, bear, close, tradeSize , Color.ORANGE, Color.ORANGE, "MACD SMA sell @ " + close);
STUDY
Rich (BB code):
Declare Lower;

input tradesize = 1;

input price = close;

#MACD

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

plot Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
plot UpSignal = if Diff crosses above 0 then 0 else Double.NaN;
plot DownSignal = if Diff crosses below 0 then 0 else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Diff.SetDefaultColor(GetColor(5));
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"));

#SMA
input lengthema = 34;

plot AvgSMA = SimpleMovingAvg(Diff, lengthema);
 
Last edited by a moderator:
M

Montana101x

New member
I found a source to get the script from here: http://freethinkscript.blogspot.com/

Here is the CODE and hope everyone enjoys, modify it and improve and make it share it here with us.



Rich (BB code):
declare lower;

input length = 9;
input colorNormLength = 14;
input price = close;
input signalLength = 3;

def tr = ExpAverage(ExpAverage(ExpAverage(Log(price), length), length), length);

plot TRIX = (tr - tr[1]) * 10000;
plot Signal = ExpAverage(TRIX, signalLength);
plot ZeroLine = 0;

def normVal = FastKCustom(AbsValue(TRIX), colorNormLength);

TRIX.SetDefaultColor(GetColor(8));
TRIX.AssignValueColor(CreateColor(255, (240 - (100 - (if TRIX > 0 then normVal else (-normVal))) * 175 / 200), 0));
ZeroLine.SetDefaultColor(GetColor(5));
Signal.setDefaultColor(GetColor(3));
TRIX.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 
Last edited by a moderator:
markos

markos

Well-known member
VIP
Warehouse
@Montana101x
Hey Montana, It is considered in poor taste to:
  • Ask for a script to be written, THEN,
  • Not thank the coder who not only put together a strategy, but also a study the same day, and THEN,
  • Come back a week later with a different script that kinda looks the same and ask that it be coded up!
You no doubt didn't even look at the script that @mc01439 made on your behalf.
Otherwise, I'm sure you would have been thankful for the effort made.

We are here to help and learn from each other. We are more than willing to help you and then teach you how to help yourself.
Just please be considerate of other people's time.
BTW, that study is named BruceWayne_Histogram. How does anyone know if it's copyrighted or not? No Bueno, Dude!
 
Last edited:

Top