Averages - with floating levels for ThinkorSwim

Mladen

Mladen

New member
Been testing TOS for a couple of days and decided to post something here too ...
A simple indicator with a possible way to filter out the signals from a single average

Usually if a single average is used for trading decisions, the slope of an average is used for that. That has its problems - mainly that most of the averages are not smooth. This is one possible way to avoid that trap.

The indicator is using floating levels to determine the "significance" for average value change and then, based on that, shows :
  • trend
  • and signals
It uses the usual set of averages types and should not be difficult to use it



Code:
#-----------------------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------------------
#     © mladen 2020
#     [email protected]
#

input averagePeriod     = 14;
input averagePrice      = close;
input averageType       = AverageType.SMA;
input levelsPeriod      = 35;
input levelsUpPercent   = 90;
input levelsDownPercent = 10;
input showSignals       = yes;

#

plot average = MovingAverage(averageType, averagePrice, averagePeriod);
        def minAverage = Lowest(average, Max(levelsPeriod, 1));
        def maxAverage = Highest(average, Max(levelsPeriod, 1));
plot levelUp   = minAverage + (maxAverage - minAverage) * levelsUpPercent / 100.0;
plot levelDown = minAverage + (maxAverage - minAverage) * levelsDownPercent / 100.0;

average.SetLineWeight(2);
average.DefineColor("up", GetColor(6));
average.DefineColor("neutral", GetColor(7));
average.DefineColor("down", GetColor(2));
average.AssignValueColor(if average > levelUp then average.Color("up") else if average < levelDown then average.Color("down") else average.Color("neutral"));

levelUp.SetDefaultColor(GetColor(6));
levelDown.SetDefaultColor(GetColor(2));
levelUp.SetStyle(Curve.SHORT_DASH);
levelDown.SetStyle(Curve.SHORT_DASH);

plot upSignalCross   = if average crosses above levelUp then levelUp else Double.NaN;
     upSignalCross.SetHiding(!showSignals);
     upSignalCross.SetDefaultColor(GetColor(6));
     upSignalCross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
     upSignalCross.HideBubble();
plot downSignalCross = if average crosses below levelDown then levelDown else Double.NaN;
     downSignalCross.SetHiding(!showSignals);
     downSignalCross.SetDefaultColor(GetColor(2));
     downSignalCross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
     downSignalCross.HideBubble();
 
Last edited by a moderator:
BenTen

BenTen

Administrative
Staff
VIP
@Ramesh16 Please be specific. What doesn't work? Did you get an error message? If so, what does it say?
 
BenTen

BenTen

Administrative
Staff
VIP
@Ramesh16 Please include a screenshot of the error, that way we can look into it and help you troubleshoot.
 
Mladen

Mladen

New member
Here is a link to shared script averages with floating levels https://tos.mx/ZrHBa8u

Works as expected (no errors)

PS: the example picture from post 1 was made using Wilders ema (all the rest of the parameters are default)
 
Last edited by a moderator:
D

Danzig

New member
Are you the same Mladen from the meta trader forums?
 
technicallydreaming

technicallydreaming

Member
Not saying anyone should do this, but you could have used only this indicator on the /ES today and made a lot of $$$.
 
Last edited:

Similar threads

Top