Dublin_Capital
Member
This isn't any kind of groundbreaking code, but I thought it might save somebody a little time.
This study posts up to four Hourly SMAs, and five Daily SMAs, as well as the previous day's High, Low, and Close on one chart. It gives alerts when price crosses the moving averages. User can choose the length of the Moving Averages.
The main benefit is that you can see the hourly / daily moving averages on any smaller time frame charts, without making adjustments.
I usually combine this study with daily and weekly pivot point studies, and before each session I take notice of areas where multiple "levels" intersect, and also which moving averages seem to be most relevant to my timeframe. I turn off alerts for any SMAs that don't seem to be relevant.
Hope this is helpful.
This study posts up to four Hourly SMAs, and five Daily SMAs, as well as the previous day's High, Low, and Close on one chart. It gives alerts when price crosses the moving averages. User can choose the length of the Moving Averages.
The main benefit is that you can see the hourly / daily moving averages on any smaller time frame charts, without making adjustments.
I usually combine this study with daily and weekly pivot point studies, and before each session I take notice of areas where multiple "levels" intersect, and also which moving averages seem to be most relevant to my timeframe. I turn off alerts for any SMAs that don't seem to be relevant.
Hope this is helpful.
Code:
#DS_Levels
#Combines many important daily and hourly levels in one study
#Copyright Confluence Capital Group
#2018-04-19
#Saving CPU
declare once_per_bar;
#User Inputs
input HourlySMAPeriod1 = 20;
input HourlySMAPeriod2 = 50;
input HourlySMAPeriod3 = 100;
input HourlySMAPeriod4 = 200;
input DailySMAPeriod1 = 10;
input DailySMAPeriod2 = 20;
input DailySMAPeriod3 = 50;
input DailySMAPeriod4 = 100;
input DailySMAPeriod5 = 200;
input ShowOnlyToday = yes;
#Definitions
def HourlyClose = close(period = AggregationPeriod.HOUR);
def DailyClose = close(period = AggregationPeriod.DAY);
#Plots
plot HourlySMA1 = Average(HourlyClose, HourlySMAPeriod1);
plot HourlySMA2 = Average(HourlyClose, HourlySMAPeriod2);
plot HourlySMA3 = Average(HourlyClose, HourlySMAPeriod3);
plot HourlySMA4 = Average(HourlyClose, HourlySMAPeriod4);
plot DailySMA1 = Average(DailyClose, DailySMAPeriod1);
plot DailySMA2 = Average(DailyClose, DailySMAPeriod2);
plot DailySMA3 = Average(DailyClose, DailySMAPeriod3);
plot DailySMA4 = Average(DailyClose, DailySMAPeriod4);
plot DailySMA5 = Average(DailyClose, DailySMAPeriod5);
plot YesterdayHigh = high(period = AggregationPeriod.DAY)[1];
plot YesterdayLow = low(period = AggregationPeriod.DAY)[1];
plot YesterdayClose = close(period = AggregationPeriod.DAY)[1];
#Format Plots
HourlySMA1.SetDefaultColor(Color.CYAN);
HourlySMA1.SetLineWeight(1);
HourlySMA2.SetDefaultColor(Color.ORANGE);
HourlySMA2.SetLineWeight(1);
HourlySMA3.SetDefaultColor(Color.PINK);
HourlySMA3.SetLineWeight(1);
HourlySMA4.SetDefaultColor(Color.GRAY);
HourlySMA4.SetLineWeight(1);
DailySMA1.SetDefaultColor(Color.PLUM);
DailySMA1.SetLineWeight(2);
DailySMA1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailySMA2.SetDefaultColor(Color.CYAN);
DailySMA2.SetLineWeight(2);
DailySMA2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailySMA3.SetDefaultColor(Color.ORANGE);
DailySMA3.SetLineWeight(2);
DailySMA3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailySMA4.SetDefaultColor(Color.PINK);
DailySMA4.SetLineWeight(2);
DailySMA4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailySMA5.SetDefaultColor(Color.GRAY);
DailySMA5.SetLineWeight(2);
DailySMA5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
YesterdayHigh.SetDefaultColor(Color.GREEN);
YesterdayLow.SetDefaultColor(Color.RED);
YesterdayClose.SetDefaultColor(Color.DARK_GRAY);
#Chart Bubbles
def LastBar = !IsNaN(open) and IsNaN(open [-1] ) ;
def BubbleLocation = LastBar[10];
AddChartBubble(BubbleLocation, DailySMA1, DailySMAPeriod1 + "d", Color.PINK, yes);
AddChartBubble(BubbleLocation, DailySMA2, DailySMAPeriod2 + "d", Color.GREEN, yes);
AddChartBubble(BubbleLocation, DailySMA3, DailySMAPeriod3 + "d", Color.BLUE, yes);
AddChartBubble(BubbleLocation, DailySMA4, DailySMAPeriod4 + "d", Color.PLUM, yes);
AddChartBubble(BubbleLocation, DailySMA5, DailySMAPeriod5 + "d", Color.GRAY, yes);
#Defining support / Resistance
def Daily1Action = close crosses DailySMA1;
def Daily2Action = close crosses DailySMA2;
def Daily3Action = close crosses DailySMA3;
def Daily4Action = close crosses DailySMA4;
def Daily5Action = close crosses DailySMA5;
def Hourly1Action = close crosses HourlySMA1;
def Hourly2Action = close crosses HourlySMA2;
def Hourly3Action = close crosses HourlySMA3;
def Hourly4Action = close crosses HourlySMA4;
#Alerts
Alert(Daily1Action, "Daily " + DailySMAPeriod1 + "SMA", Alert.bar, Sound.Ding);
Alert(Daily2Action, "Daily " + DailySMAPeriod2 + "SMA", Alert.BAR, Sound.Ding);
Alert(Daily3Action, "Daily " + DailySMAPeriod3 + "SMA", Alert.BAR, Sound.Ding);
Alert(Daily4Action, "Daily " + DailySMAPeriod4 + "SMA", Alert.BAR, Sound.Ding);
Alert(Daily5Action, "Daily " + DailySMAPeriod5 + "SMA", Alert.BAR, Sound.Ding);
Alert(Hourly1Action, "Hourly " + HourlySMAPeriod1 + "SMA", Alert.BAR, Sound.Ding);
Alert(Hourly2Action, "Hourly " + HourlySMAPeriod2 + "SMA", Alert.BAR, Sound.Ding);
Alert(Hourly3Action, "Hourly " + HourlySMAPeriod3 + "SMA", Alert.BAR, Sound.Ding);
Alert(Hourly4Action, "Hourly " + HourlySMAPeriod4 + "SMA", Alert.BAR, Sound.Ding);
Last edited: