FXCloud

Triple Switch

65
my favorite

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?
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=21)
//Mult=input(0,title="ATR Multiplier", minval=0.0001)
OS=input(0,title="Offset",type=integer)
Longsource= WTC?close:low
Shortsource= WTC?close:high
Longstart= iff(high>=highest(high,BB),lowest(low,BB),Longstart[1])//+Mult*sum(high-low,ATRPeriod)/ATRPeriod
Shortstart= iff(low<=lowest(low,BB),highest(high,BB),Shortstart[1])//-Mult*sum(high-low,ATRPeriod)/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,offset=OS)