파인스크립트 기본반
분류 예제

요일별 일간 평균 변동폭

페이지 정보

본문


위 영상에서 사용한 일간 요일별 평균 변동폭 스크립트입니다.



[일간 요일별 평균 변동폭 (몸통 기준)]


//@version=4
study("일간 요일별 평균 변동폭 (몸통 기준)")
var accRangeMon = 0.0
var accRangeTue = 0.0
var accRangeWed = 0.0
var accRangeThu = 0.0
var accRangeFri = 0.0
var accRangeSat = 0.0
var accRangeSun = 0.0

var avgAccMon = 0.0
var avgAccTue = 0.0
var avgAccWed = 0.0
var avgAccThu = 0.0
var avgAccFri = 0.0
var avgAccSat = 0.0
var avgAccSun = 0.0

range = abs(open-close) / open * 100

accRangeMon := accRangeMon + (dayofweek==2 ? range : 0)
accRangeTue := accRangeTue + (dayofweek==3 ? range : 0)
accRangeWed := accRangeWed + (dayofweek==4 ? range : 0)
accRangeThu := accRangeThu + (dayofweek==5 ? range : 0)
accRangeFri := accRangeFri + (dayofweek==6 ? range : 0)
accRangeSat := accRangeSat + (dayofweek==7 ? range : 0)
accRangeSun := accRangeSun + (dayofweek==1 ? range : 0)

nthDay = floor((bar_index)/7)+1

avgAccMon := dayofweek==2 ? accRangeMon / nthDay : avgAccMon
avgAccTue := dayofweek==3 ? accRangeTue / nthDay : avgAccTue
avgAccWed := dayofweek==4 ? accRangeWed / nthDay : avgAccWed
avgAccThu := dayofweek==5 ? accRangeThu / nthDay : avgAccThu
avgAccFri := dayofweek==6 ? accRangeFri / nthDay : avgAccFri
avgAccSat := dayofweek==7 ? accRangeSat / nthDay : avgAccSat
avgAccSun := dayofweek==1 ? accRangeSun / nthDay : avgAccSun

plot(avgAccMon, "MON", color.red)
plot(avgAccTue, "TUE", color.orange)
plot(avgAccWed, "WED", color.yellow)
plot(avgAccThu, "THU", color.green)
plot(avgAccFri, "FRI", color.blue)
plot(avgAccSat, "SAT", color.navy)
plot(avgAccSun, "SUN", color.purple)



[일간 요일별 평균 변동폭 (꼬리 기준)] 


//@version=4
study("일간 요일별 평균 변동폭 (꼬리 기준)")
var accRangeMon = 0.0
var accRangeTue = 0.0
var accRangeWed = 0.0
var accRangeThu = 0.0
var accRangeFri = 0.0
var accRangeSat = 0.0
var accRangeSun = 0.0

var avgAccMon = 0.0
var avgAccTue = 0.0
var avgAccWed = 0.0
var avgAccThu = 0.0
var avgAccFri = 0.0
var avgAccSat = 0.0
var avgAccSun = 0.0

range = abs(high-low) / low * 100

accRangeMon := accRangeMon + (dayofweek==2 ? range : 0)
accRangeTue := accRangeTue + (dayofweek==3 ? range : 0)
accRangeWed := accRangeWed + (dayofweek==4 ? range : 0)
accRangeThu := accRangeThu + (dayofweek==5 ? range : 0)
accRangeFri := accRangeFri + (dayofweek==6 ? range : 0)
accRangeSat := accRangeSat + (dayofweek==7 ? range : 0)
accRangeSun := accRangeSun + (dayofweek==1 ? range : 0)

nthDay = floor((bar_index)/7)+1

avgAccMon := dayofweek==2 ? accRangeMon / nthDay : avgAccMon
avgAccTue := dayofweek==3 ? accRangeTue / nthDay : avgAccTue
avgAccWed := dayofweek==4 ? accRangeWed / nthDay : avgAccWed
avgAccThu := dayofweek==5 ? accRangeThu / nthDay : avgAccThu
avgAccFri := dayofweek==6 ? accRangeFri / nthDay : avgAccFri
avgAccSat := dayofweek==7 ? accRangeSat / nthDay : avgAccSat
avgAccSun := dayofweek==1 ? accRangeSun / nthDay : avgAccSun

plot(avgAccMon, "MON", color.red)
plot(avgAccTue, "TUE", color.orange)
plot(avgAccWed, "WED", color.yellow)
plot(avgAccThu, "THU", color.green)
plot(avgAccFri, "FRI", color.blue)
plot(avgAccSat, "SAT", color.navy)
plot(avgAccSun, "SUN", color.purple)

관련자료

등록된 댓글이 없습니다.
전체 21건 / 1페이지

+ 최근글


+ 새댓글


통계