Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
BB Stops From Thinkscript custom indicator
Collapse
X
-
BB Stops From Thinkscript custom indicator
Hi All, I am looking for something like the cyan/ magenta dots seen on the attached chart. Basically like an ATR trailing stop but instead it uses Bollinger Bands to calculate not sure exactly. Please help! This indicator is very important to my trading visually. The code is not copyrighted or being sold anywhere. I can post here if it is not against the rules. -Chris1 PhotoTags: None
-
Originally posted by s.kinra View PostHello,
I guess its using upper band to trail sl for short trades & lower band for long trades. This actually is simple to plot, you can use 2 plots & achieve it.
input baseMA = {default sma, ema, wma, vwma, swma, dema, hullema, tema};
input length = 20;
input mult = 1; #hint mult: 0.001 to 50
input colorFill = yes;
def vClose = close;
def bn = BarNumber();
def nan = double.NaN;
def ema1 = MovingAverage(AverageType.EXPONENTIAL, vClose, length);
def ema2 = MovingAverage(AverageType.EXPONENTIAL, ema1, length);
def ema3 = MovingAverage(AverageType.EXPONENTIAL, ema2, length);
def tema = 3 * (ema1 - ema2) + ema3;
def wma = MovingAverage(AverageType.WEIGHTED, vClose, length);
def basis;
switch (baseMA)
{
case sma: basis = MovingAverage(AverageType.SIMPLE, vClose, length);
case ema: basis = MovingAverage(AverageType.EXPONENTIAL, vClose, length);
case wma: basis = MovingAverage(AverageType.WEIGHTED, vClose, length);
case vwma: basis = MovingAverage(AverageType.EXPONENTIAL, vClose, length);
case swma: basis = wma[3]/6 + 2*wma[2]/6 + 2*wma[1]/6 + wma;
case dema: basis = ema2;
case hullema: basis = MovingAverage(AverageType.HULL, vClose, length);
case tema: basis = tema;
}
def dev = mult * stdev(vClose, length);
def upper = basis + dev;
def lower = basis - dev;
def up = if bn == 1
then nan
else if Crosses(vClose, upper, CrossingDirection.ABOVE)
then 1
else if Crosses(vClose, lower, CrossingDirection.BELOW)
then 0
else up[1];
def dn = if bn == 1
then nan
else if Crosses(vClose, lower, CrossingDirection.BELOW)
then 1
else if Crosses(vClose, upper, CrossingDirection.ABOVE)
then 0
else dn[1];
def changeUp = dn[1] and up;
def changeDn = up[1] and dn;
def stopLine = if up then lower else if dn then upper else nan;
plot p1 = stopLine;
p1.SetLineWeight(2);
p1.AssignValueColor(if stopLine == upper then Color.Magenta else Color.Cyan);
#plot pChangeDn = if changeDn then lower else nan;
#plot pChangeUp = if changeUp then upper else nan;
#pChangeDn.SetPaintingStrategy(PaintingStrategy.BO OLEAN_ARROW_DOWN);
#pChangeUp.SetPaintingStrategy(PaintingStrategy.BO OLEAN_ARROW_UP);
#pChangeDn.SetDefaultColor(Color.Red);
#pChangeUp.SetDefaultColor(Color.Green);
Comment
-
Hello Chris,
You can work around a new indicator for this & use the intended logic, actually its easy, if stuck anywhere will surely help. Use new indicator wizard to get started. SWMA is not available by default all others are included in NT8 so you can simply invoke them.Last edited by s.kinra; 10-22-2020, 01:48 AM.
- Likes 1
Comment
-
Hello technicallydreaming,
Thanks for your post and welcome to the NinjaTrader forums!
If you would like to create this yourself, we can provide links to get you started in a general way with Ninjascript which is based on C# programming language.
If you would like this created for you, we can provide a link to 3rd party programmers in the NinjaTrader Ecosystem.Paul H.NinjaTrader Customer Service
- Likes 1
Comment
-
Originally posted by NinjaTrader_PaulH View PostHello technicallydreaming,
Thanks for your post and welcome to the NinjaTrader forums!
If you would like to create this yourself, we can provide links to get you started in a general way with Ninjascript which is based on C# programming language.
If you would like this created for you, we can provide a link to 3rd party programmers in the NinjaTrader Ecosystem.
- Likes 1
Comment
-
- Likes 1
Comment
-
Originally posted by s.kinra View PostHello technicallydreaming,
Here you get [ATTACH]n1124174[/ATTACH] , just in case you still need it.
Comment
-
-
Originally posted by s.kinra View PostOK, so what exactly is your doubt now? I can add Volume to tick chart as well & so the Volume MA. Let me know where are you getting stuck.
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by zstheorist, Today, 07:52 PM
|
0 responses
3 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
149 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
Comment