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:
@Ramesh16 Please be specific. What doesn't work? Did you get an error message? If so, what does it say?
 
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)?
 
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...
 
@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
 
@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...???
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
302 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top