This code gives signals upon a “SuperTrend.” calculated with HeikinAshi candlesticks. It’s a way of showing where the general direction of a market (like stocks or currencies) is heading.
Here’s how it works:
- **Setting up the Basics**: At the start, there are some basic settings – a sensitivity key and a period. The sensitivity key makes the tool more or less reactive. The period refers to how many past data points we’re looking at to help make decisions.
- **True Average Range**: The code then calculates something called the “average true range.” Think of this as a way to measure how much prices are moving around.
- **Setting Upper and Lower Boundaries**: Using the average true range, it sets two boundaries: an upper one and a lower one. These boundaries help us determine if the market is going upwards or downwards.
- **Trend Determination**: If the current price goes above the upper boundary from the previous time, we think the trend is upwards. If it goes below the lower boundary, the trend is downwards.
- **Flags**: These are just little markers to help us remember if the trend just changed direction. For example, if it was going upwards and suddenly changes downwards, we set a flag.
- **Adjusting Boundaries**: If the market is moving upwards and the lower boundary drops, we stick with the previous boundary. Similarly, if the market is moving downwards and the upper boundary rises, we stick with the previous boundary. But, if a trend change was flagged, we reset our boundaries.
- **Choosing SuperTrend Value**: Depending on the trend (upwards or downwards), our SuperTrend value will equal one of the boundaries.
- **Color Coding**: If the SuperTrend value is rising, it will be colored green. If it’s dropping, it will be colored red.
- **Drawing Arrows**: If the price crosses over the SuperTrend value going up, a green arrow is drawn. If it crosses going down, a red arrow is drawn. These arrows give a visual cue about where the market is heading.
- **Final Result**: The code finally gives out the SuperTrend value, color-coded based on its direction, to visually indicate where the market might be heading.
So, in essence, this code helps traders see, at a glance, whether a market is trending upwards or downwards and gives visual cues when that trend might be changing.
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 |
a = 1 //Key Vaule. ‘This changes the sensitivity' c = 10 //ATR Period multiplier=a period=10 moy=averagetruerange[period](close) iprice=totalprice up=iprice+multiplier*moy dn=iprice-multiplier*moy once trend=1 if close>up[1] then trend=1 elsif close<dn[1] then trend=-1 endif if trend<0 and trend[1]>0 then flag=1 else flag=0 endif if trend>0 and trend[1]<0 then flagh=1 else flagh=0 endif if trend>0 and dn<dn[1] then dn=dn[1] endif if trend<0 and up>up[1] then up=up[1] endif if flag=1 then up=iprice+multiplier*moy endif if flagh=1 then dn=iprice-multiplier*moy endif if trend=1 then mysupertrend=dn else mysupertrend=up endif if mysupertrend > mysupertrend[1] then color1=0 color2=255 color3=0 elsif mysupertrend < mysupertrend[1] then color1=255 color2=0 color3=0 endif if iprice crosses over mysupertrend then drawarrowup(barindex,mysupertrend) coloured("green") endif if iprice crosses under mysupertrend then drawarrowdown(barindex,mysupertrend) coloured("red") endif return mysupertrend coloured (color1,color2,color3) as "SuperTrend" |
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 :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
hi nicolas you are the best
the big secrets we have in the little details
Går det att göra något automatiskt script till signalerna ?
Simple strategy with this indicator is available here: https://www.prorealcode.com/topic/ut-bot-alerts-2/#post-218578
Nicolas…. MERCI 1 millions de fois, cet indicateur gagne dans 75% des cas en scalping m1 …
bonjour, à quel moment apparait le fleche, à l’ouverture ou la fermeture de la bougie?
merci
Bonjour, est-il possible d’ajouter une alarme sonore sur PRT à l’apparition des flèches ? Bravo pour cet indicateur sacré travaille !!