FXCloud

Triple Switch

130 0 14
AWESOME SAR             type indicator
Remove from Favorite Scripts Add to Favorite Scripts
study("Triple Switch", overlay=true)
BB=input(2, title="Bars Back", minval=1)
WTC=input(true,title="Wait Until Close",type=bool)
Pips=input(2,title="Close Past")
//ATRPeriod=input(title="ATR Period", type=integer, defval=22)
//Mult=input(title="ATR Multiplier", type=integer, defval=3)
Longsource= WTC?close:low
Shortsource= WTC?close:high
Longstart= iff(high>=highest(high,BB),lowest(low,BB),Longstart[1])//+Mult*atr(ATRPeriod)
Shortstart= iff(low<=lowest(low,BB),highest(high,BB),Shortstart[1])//-Mult*atr(ATRPeriod)
Switchtolong=iff ((Shortsource-(Pips*syminfo.mintick))>=Shortstart and (Shortsource-(Pips*syminfo.mintick))[1]<Shortstart[1] , 1 ,  0)
Switchtoshort=iff ((Longsource+(Pips*syminfo.mintick))<=Longstart and (Longsource+(Pips*syminfo.mintick))[1]>Longstart[1] ,  1 ,  0)
direction= iff (na(direction[1]), 0, 
            iff (direction[1]<=0 and Switchtolong, 1, 
            iff (direction[1]>=0 and Switchtoshort, -1, direction[1])))
Tripleswitch= direction>0?Longstart:Shortstart
plot(Tripleswitch, color=direction>0?green:red, style=line, linewidth=2)

United States
United Kingdom
India
Deutschland
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing Priority Support Ideas Published Followers Following Private Messages Chat Sign Out