Higher TFs Supertrends on 5min

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #97454 quote
    segiesegie
    Participant
    Senior

    Good day,

    I found this code in the library. I’m looking to to add a 4hr and 1hr Supertrend setting ( e.g  3:10 of each) on a 5min chart. Is it possible?

    Regards,

    Segie

    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"
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Higher TFs Supertrends on 5min


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
segie @segie Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/01/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...