Averages - with floating levels for ThinkorSwim

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

Capture.png


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:

homeplate2

Member
VIP
Not saying anyone should do this, but you could have used only this indicator on the /ES today and made a lot of $$$.
how would you put an alarm on this so when the down signal cross happens you get one sound and when an up signal cross happens you get another sound and what time frame would you use during a trading day (ticks or minutes)?
 

rad14733

Well-known member
VIP
how would you put an alarm on this so when the down signal cross happens you get one sound and when an up signal cross happens you get another sound and what time frame would you use during a trading day (ticks or minutes)?
An Alert() in A Chart Study will provide the most instantaneous alert where as other types of alerts can be somewhat delayed, such as text alerts... The alerts would be based on the crossover itself...

For Day Trading the timeframe is up to you and depends on what you are trading as far as Ticks vs Time... I scalp and day trade and I monitor multiple timeframes... My current setup has one 4-up Window that only monitors the chart with a few indicators in 3m, 5m, 10m, and 15m timeframes... I have other windows with additional indicators in 5m, 15m, and 30m timeframes... Then I have a trading window with a 5m chart and my Active Trader and Time & Sales panels... I scalp options but monitor the underlying, primarily, and have two smaller panels on the right... The upper and lower panels can either have a Call on top and Put on the bottom, or can have the option chart in one panel and AT and T&S in the other... It's a versatile setup for not running on extremely high resolution displays... And when I run Renko Bar charts I mainly use ATR for tick count but reduce tick counts across the 4-up charts... I can provide images upon request...

Hope this helps...
 

MerryDay

Administrative
Staff member
Staff
VIP
@kabira I also had no problem with your chart setup. Perhaps it is your timeframe duration???? 1D5min is not providing very many data points to work with. Consider going up to at least 20 days and see if that solves the issue?
HTH
 

rad14733

Well-known member
VIP
@kabira I also had no problem with your chart setup. Perhaps it is your timeframe duration???? 1D5min is not providing very many data points to work with. Consider going up to at least 20 days and see if that solves the issue?
HTH

@MerryDay That was how I tested, with the exact same settings overall, and all everything displayed as expected...

@kabira Were you doing all testing on a single chart, or in multiple detached charts...???
 

Similar threads

Top