1. 首页
  2. 易语言 - EasyLanguage
  3. 用着色条突显每月的特定日期PaintBar to Highlight Specific Day of Month

用着色条突显每月的特定日期PaintBar to Highlight Specific Day of Month

本文用具体实例描述如何突显每个月的某一个交易日和某一个周五。

An example of PaintBar study code which highlights a specific trading day of each month (user specified) and a specific Friday of each month (user specified) is shown below. Comments were added to this code to explain its operation. You will likely have to customize this code to meet your requirements.

inputs: 
	HighlightDay( 8 ),  
	HighlightFriday( 3 ), 
	HighlightDayColor( Blue ), 
	HighlightFridaysColor( Magenta ) ; 
 
variables: 
	MonthTradingDay( 0 ), 
	MonthFridays( 0 ) ; 
 
//  If a change in month is detected on the current bar, then 
//  reset the counters which track the trading day of the month 
//  and the number of fridays since the beginning of the month. 
if Month( Date ) <> Month ( Date[1] ) then 
	begin 
	MonthTradingDay = 1 ; 
	MonthFridays = 0 ; 
	end 
else  
	MonthTradingDay = MonthTradingDay + 1 ; 
	 
//  If there has been a date change between the current bar 
//  and the prior bar, then increment the number of Fridays 
//  if the new date corresponds to a Friday 
if Date <> Date[1] and DayOfWeek(Date) = 5 then 
	MonthFridays = MonthFridays + 1 ; 
	 
//  If the trading day of the month corresponds to the 
//  day to highlight, then highlight this day 
if 	HighlightDay = MonthTradingDay then 
	PlotPB( High, Low, "PB", HighlightDayColor ) ; 
 
//  If the number of fridays corresponds to the  
//  number to highlight, then highlight this friday. 
//  Also, reset the MonthFridays to a huge number following this 
//  so we don't paint the next 5 days (next week) as the MonthFridays only  
//  increases once per week. 
if MonthFridays = HighlightFriday then 
	begin 
	PlotPB( High, Low, "PB", HighlightFridaysColor ) ; 
	MonthFridays = 9999 ; 
	end ; 

An example of inserting this PaintBar indicator on a daily chart is shown below. The Blue bars highlight the user specified trading day of each month (8th day in this example) and the Magenta bars highlight the user specified Friday of each month (3rd in this case).

更新于 2020年6月5日

这篇文章对您有帮助吗?

相关的话题

留言评论