Hide moving average lines on different timeframe on one chart?

AnakManis

New member
Due to limitation on number of screens, I use one chart that I often switch from Max W chart, 1Y 1D chart, 180D 4h chart, to 1D 5m chart to create support and resistant.

I use 4 moving average(MA)s, which I played around into 1 study.
They are the 13 EMA, 20 EMA, 50 SMA, and 200 SMA.

For awhile, it was working fine. However, overtime I've found myself putting too many support and resistant lines that the MA lines were getting harder to read.

So, I tried using SetHiding to hide the 13 & 20 EMAs and only show the 50 & 200 SMAs when I'm switching to Max W & 1Y 1D charts and vice versa on hiding the 50 & 200 SMAs and showing 13 & 20 EMAs when switching to 180D 4h & 1D 5m chart.

I don't know what I'm doing, but if anyone can take a stab at it, rearrange, or give me a constructive criticism on how to fix the code, it would be very much appreciated. Thanks in advance.

Here's the code:

Code:
#= MOVING AVERAGES =========================================================#
# INPUTS FOR MOVING AVERAGE #
input EMA1 = 13;
input EMA2 = 20;
input SMA1 = 50;
input SMA2 = 200;
input Displace = 0;
input AverageType1 = {"SIMPLE", default "EXPONENTIAL", "WEIGHTED", "WILDERS", "HULL"};
input AverageType2 = {default "SIMPLE", "EXPONENTIAL", "WEIGHTED", "WILDERS", "HULL"};

# PLOTS FOR MOVING AVERAGE #
plot FirstMA = MovingAverage(AverageType1, close[-Displace], EMA1);
plot SecondMA = MovingAverage(AverageType1, close[-Displace], EMA2);
plot ThirdMA = MovingAverage(AverageType2, close[-Displace], SMA1);
plot FourthMA = MovingAverage(AverageType2, close[-Displace], SMA2);

# SET HIDING FOR MOVING AVERAGE #
FirstMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.MIN);
SecondMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.MIN);
ThirdMA.SetHiding(GetAggregationPeriod() <= AggregationPeriod.DAY);
SecondMA.SetHiding(GetAggregationPeriod() <= AggregationPeriod.DAY);

# DEFINE GLOBAL COLOR FOR MOVING AVERAGE #
DefineGlobalColor("MA1", (CreateColor(153, 204, 255)));
DefineGlobalColor("MA2", (CreateColor(0, 128, 255)));
DefineGlobalColor("MA3", (CreateColor(204, 153, 255)));
DefineGlobalColor("MA4", (CreateColor(127, 0, 255)));


# SET DEFAULT COLOR FOR MOVING AVERAGE #
FirstMA.SetDefaultColor (GlobalColor("MA1"));
SecondMA.SetDefaultColor (GlobalColor("MA2"));
ThirdMA.SetDefaultColor (GlobalColor("MA3"));
FourthMA.SetDefaultColor (GlobalColor("MA4"));

# SET LINE WEIGHT FOR MOVING AVERAGE #
FirstMA.SetLineWeight(1);
SecondMA.SetLineWeight(1);
ThirdMA.SetLineWeight(1);
FourthMA.SetLineWeight(1);
#= MOVING AVERAGE =========================================================#
 
@AnakManis
Try this:
Create 4 charts and set each one up w/ your 4 different aggregations and customize your averages to each chart. Then right-click on any chart and click 'maximize cell'
V8fCKfj.png

Now to scroll through your charts, click on the arrows at the top of the screen.
yyTFnei.png


Here is a share link to the grid shown in this post: http://tos.mx/ArEYlOZ
HTH
 

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

@AnakManis
Try this:
Create 4 charts and set each one up w/ your 4 different aggregations and customize your averages to each chart. Then right-click on any chart and click 'maximize cell'
V8fCKfj.png

Now to scroll through your charts, click on the arrows at the top of the screen.
yyTFnei.png


Here is a share link to the grid shown in this post: http://tos.mx/ArEYlOZ
HTH
Is there a way to do this on a flexible grid? And can I see 2 MAs at a time instead of 4?

Here's the mess that I usually see every day.
cr1jcnj.png
 
@AnakManis Not totally sure what you are asking.
If you are asking does TOS allow multiple flexible grids that can be leafed through like we do w/ the charts above?
I believe the answer is no.
 
Due to limitation on number of screens, I use one chart that I often switch from Max W chart, 1Y 1D chart, 180D 4h chart, to 1D 5m chart to create support and resistant.

I use 4 moving average(MA)s, which I played around into 1 study.
They are the 13 EMA, 20 EMA, 50 SMA, and 200 SMA.

For awhile, it was working fine. However, overtime I've found myself putting too many support and resistant lines that the MA lines were getting harder to read.

So, I tried using SetHiding to hide the 13 & 20 EMAs and only show the 50 & 200 SMAs when I'm switching to Max W & 1Y 1D charts and vice versa on hiding the 50 & 200 SMAs and showing 13 & 20 EMAs when switching to 180D 4h & 1D 5m chart.

I don't know what I'm doing, but if anyone can take a stab at it, rearrange, or give me a constructive criticism on how to fix the code, it would be very much appreciated. Thanks in advance.

Here's the code:

Code:
#= MOVING AVERAGES =========================================================#
# INPUTS FOR MOVING AVERAGE #
input EMA1 = 13;
input EMA2 = 20;
input SMA1 = 50;
input SMA2 = 200;
input Displace = 0;
input AverageType1 = {"SIMPLE", default "EXPONENTIAL", "WEIGHTED", "WILDERS", "HULL"};
input AverageType2 = {default "SIMPLE", "EXPONENTIAL", "WEIGHTED", "WILDERS", "HULL"};

# PLOTS FOR MOVING AVERAGE #
plot FirstMA = MovingAverage(AverageType1, close[-Displace], EMA1);
plot SecondMA = MovingAverage(AverageType1, close[-Displace], EMA2);
plot ThirdMA = MovingAverage(AverageType2, close[-Displace], SMA1);
plot FourthMA = MovingAverage(AverageType2, close[-Displace], SMA2);

# SET HIDING FOR MOVING AVERAGE #
FirstMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.MIN);
SecondMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.MIN);
ThirdMA.SetHiding(GetAggregationPeriod() <= AggregationPeriod.DAY);
SecondMA.SetHiding(GetAggregationPeriod() <= AggregationPeriod.DAY);

# DEFINE GLOBAL COLOR FOR MOVING AVERAGE #
DefineGlobalColor("MA1", (CreateColor(153, 204, 255)));
DefineGlobalColor("MA2", (CreateColor(0, 128, 255)));
DefineGlobalColor("MA3", (CreateColor(204, 153, 255)));
DefineGlobalColor("MA4", (CreateColor(127, 0, 255)));


# SET DEFAULT COLOR FOR MOVING AVERAGE #
FirstMA.SetDefaultColor (GlobalColor("MA1"));
SecondMA.SetDefaultColor (GlobalColor("MA2"));
ThirdMA.SetDefaultColor (GlobalColor("MA3"));
FourthMA.SetDefaultColor (GlobalColor("MA4"));

# SET LINE WEIGHT FOR MOVING AVERAGE #
FirstMA.SetLineWeight(1);
SecondMA.SetLineWeight(1);
ThirdMA.SetLineWeight(1);
FourthMA.SetLineWeight(1);
#= MOVING AVERAGE =========================================================#
The grid solution is excellent. If you still want to use your code, here is a substitute for your hiding code section that should help:

# SET HIDING FOR MOVING AVERAGE #
FirstMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
SecondMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
ThirdMA.SetHiding(GetAggregationPeriod() < AggregationPeriod.FOUR_HOURS);
FourthMA.SetHiding(GetAggregationPeriod() < AggregationPeriod.FOUR_HOURS);
 
@SleepyZ Yes, you can do the same with a Flexible Grid... I use more Flexible Grids that I do multiple panel charts... I usually have at least five Flexible Grids open, one 4-Up Chart Grid, and a mix of other windows and panels... And that's just on my laptop... I also run multiple of everything on my three display trading station that consists of a PC with two displays and an All-In-One PC...

Here is an example of cycling through Flexible Grid panels...

AK5scBv.png


nyaaC1z.png


NzGulV3.png


WnuTZnv.png
 
@rad14733 in post #6 ...the first picture....

you have the underlying PLUG on the left and the plug option on the right, i noticed your charts arent linked,
when you type PLUG to the left chart ... do you have to manually add the Plug option to the right? (or visa versa, you type option on the right chart and manually type the underlying on the left)?? or did you figure out a way so the underlying automatically populates to the left when typing the option on the right?
 
The grid solution is excellent. If you still want to use your code, here is a substitute for your hiding code section that should help:

# SET HIDING FOR MOVING AVERAGE #
FirstMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
SecondMA.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
ThirdMA.SetHiding(GetAggregationPeriod() < AggregationPeriod.FOUR_HOURS);
FourthMA.SetHiding(GetAggregationPeriod() < AggregationPeriod.FOUR_HOURS);
Thank you guys for all your help. But this is the one that I was looking for. Now, I can switch between different time frames and only see 2 EMAs on less than 4 hours time frame and 2 SMAs on anything greater than 4 hours time frame. Thanks again to all.
 
@rad14733 in post #6 ...the first picture....

you have the underlying PLUG on the left and the plug option on the right, i noticed your charts arent linked,
when you type PLUG to the left chart ... do you have to manually add the Plug option to the right? (or visa versa, you type option on the right chart and manually type the underlying on the left)?? or did you figure out a way so the underlying automatically populates to the left when typing the option on the right?

Good question, and one I was asked by someone I am mentoring to help his trading practices just yesterday... It isn't possible to link an option to an underlying symbol for auto-population of the panels...

Instead, if you select a Link Color/Number, like Purple 5, for both right panels, then when you are on the Trade Tab viewing the Option Chain you simply Right Click on your selected option and select the bottom option, Send <option>To and both panels get populated... Or just Right Click and select Copy <option> and Paste in both panels, which is what I do with the panels in the images due to force of habit that I'm hoping to change because sometimes I forget to populate both panels and have ended up placing an order on the wrong option... But be careful...!!! I keep multiple trade panels open and the colors have to be specific to each panel or you'll also have problems, which is why I've been using Copy & Paste, because Link Colors are limited... And while it impossible to see the Option Chain from within panel drop-downs, the information provided is very limited which makes selection risky at best... I need to see Open Interests, Delta, and Volume (after open), in order to make a potential selection... If there isn't sufficient Open Interest (1000+), Delta (0.30/-0.30), or intraday Volume, then the trade is not made... Volume is not considered for trading at the open if movement is virtually guaranteed...

Because I only scalp options, the rest of the Greeks fundamentals are not important... I am only concerned whether there is potential for activity and how much profit potential there is per dollar of underlying movement... I like to pick the 1st OTM option because it will be cheaper, meaning I can just buy more contracts with the same investment, and then the Delta will increase the further into the money the option goes... It also means that potential losses would diminish should there be a reversal as opposed to a deep ITM option... That would be more of a concern for a day trade or swing trade option purchase, however...

I will be sure to include this information in my system post as well...
 
Last edited:
@SleepyZ Yes, you can do the same with a Flexible Grid... I use more Flexible Grids that I do multiple panel charts... I usually have at least five Flexible Grids open, one 4-Up Chart Grid, and a mix of other windows and panels... And that's just on my laptop... I also run multiple of everything on my three display trading station that consists of a PC with two displays and an All-In-One PC...

Here is an example of cycling through Flexible Grid panels...

AK5scBv.png


nyaaC1z.png


NzGulV3.png


WnuTZnv.png
Hi there, I never new you could set up Grids this way, to switch between without going to the pull down menu. How did you set it up this way though? I know how to set up charts this way, but setting up grids is escaping me ... Thanks in advance.
 
Hi there, I never new you could set up Grids this way, to switch between without going to the pull down menu. How did you set it up this way though? I know how to set up charts this way, but setting up grids is escaping me ... Thanks in advance.
here is the google results for the flexible grid tutorial videos
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
309 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