This SuperTrend indicator is to be used in the daily timeframe.
This script plots the weekly Supertrend (parameters to be defined) in the daily chart.
Parameters to calculate the supertrend: Multiplier and Period. Recommendend values: Multiplier = 3; Period = 10;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
rem ********************* Weekly ST in daily timeframe ******************* rem *********************** Created by F. Sacristan ****************** rem to be used in the daily timeframe rem this script plots the weekly Supertrend (parameters to be defined) in the daily chart rem Parameters to calculate the supertrend: Multiplier and Period. REcommendend values: Multiplier = 3; Period = 10 period=10 multiplier=3 WeekNo = dayofWeek if barindex = 0 then WeekStart = 1 else if WeekNo < WeekNo[1] then WeekStart = 1 else WeekStart = 0 endif endif if WeekNo < WeekNo[1] then WClosePrev = close[1] WLow = low WHigh = high WLowPrev = WLow[1] WHighPrev = WHigh[1] else WClosePrev = WClosePrev[1] if low > WLow[1] then WLow = WLow[1] else WLow = low endif if high > WHigh[1] then WHigh = High else WHigh = WHigh[1] endif WLowPrev = WLowPrev[1] WHighPrev = WHighPrev[1] endif WMid = 0.5*(WHighPrev + WLowPrev) if barindex < Period then STUp = 0 STDown = 0 else if WeekStart = 1 then TR1 = abs(WLowPrev - WClosePrev[1]) TR2 = abs(WHighPrev - WClosePrev[1]) TR3 = abs(WHighPrev - WLowPrev) else TR1 = TR1[1] TR2 = TR2[1] TR3 = TR3[1] endif TR4 = max(TR1,TR2) TRX = max(TR3,TR4) if WeekStart = 1 then TRTrigger = TRX Counter = Counter[1]+1 else TRTrigger = 0 Counter = Counter[1] endif if Counter < Period then SumTR = TRTrigger + SumTR[1] else SumTR = 0 endif ATRAverage = SumTR/Counter if Counter < Period then ATR = ATRAverage else if WeekStart = 1 then ATR = (ATR[1]*(Period-1)+TRTrigger)/Period else ATR = ATR[1] endif endif STUpBasic = WMid + Multiplier*ATR STDownBasic = WMid - Multiplier*ATR if WeekStart = 1 then if (STUpBasic < STUp[1]) or (WClosePrev[1]>STUp[1]) then STUp = STUpBasic else STUp = STUp[1] endif else STUp = STUp[1] endif if WeekStart = 1 then if (STDownBasic > STDown) or (WClosePrev[1]< STDown[1]) then STDown = STDownBasic else STDown = STDown[1] endif else STDown = STDown[1] endif endif if barindex < Period then WeeklyST = STDown endif if barindex >= Period and WeekStart = 1 and WClosePrev[1] <= STDown[1] then WeeklyST = STUp[1] Trend = -1 elsif barindex >= Period and WeekStart =1 and WClosePrev[1] >= STUp[1] then WeeklyST = STDown[1] Trend = 1 elsif Trend = 1 then WeeklyST = STDown[1] elsif Trend = -1 then WeeklyST = STUp[1] endif return WeeklyST as "Weekly ST" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :
Filename : download the ITF files
How to import ITF files into ProRealTime platform?
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hi, Fer666 Thank you for sharing.
If I want to show daily ST on a 10_min intraday chart, can I just change the small portion code as below the rest keep as it… it should be be working right?
line 19 : change to
if WeekNo WeekNo[1] then
…
line 27: change to
if WeekStart = 1 then
….
would kindly appreciate your comment or anyone can help me?
Thanks
correction above… system had remove”not equal” signs
Line 19 : change to
if WeekNo “Not equal” WeekNo[1] then
OK… I had figured out… need more than that. Thank you anyway.