Hide moving average lines on different timeframe on one chart?

AnakManis

New member
VIP
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 =========================================================#
 

MerryDay

Administrative
Staff member
Staff
VIP
@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
 

AnakManis

New member
VIP
@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
 

SleepyZ

Well-known 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 =========================================================#
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);
 

rad14733

Well-known member
VIP
@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
 

XeoNoX

Well-known member
VIP
@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?
 

AnakManis

New member
VIP
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

Well-known member
VIP
@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:

Similar threads

Top