Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study("8 Pair Strength R2.4 updated by JustUncleL", shorttitle="8 Pair Strength", overlay=false,max_bars_back=100)
- //
- // Author: Glaz
- // Date: 17 Feb 2015
- //
- // Description:
- // This study is a version of Currency Strength Meter, that utilises TradingViews
- // built-in "True Strength Index" (TSI) function. The TSI uses moving averages
- // of the underlying momentum of a financial instrument.
- //
- // Modifications:
- // 08-Dec-2017 R2.4 by JustUncleL
- // - Added ZAR and TRY exotic pairs
- // - Changed all security calls to include FX_IDC exchange in ID.
- //
- // 19-Nov-2017 R2.2 by JustUncleL
- // - Improved labelling options.
- // - Added option to use ATR weighted (default) pair influences in the Strength calculations,
- // the overall results compared with stardard calculation though is only minor, but may help.
- //
- // 17-Nov-2017 R2.1 by JustUncleL
- // - Added max_bars_back=100 parameter to study. This should prevent
- // "index out depth" errors.
- // - Added minval/maxval limits to fast and slow.
- // - Changed order of plots so they show up in alpabetic order in the "Style"
- // parameters of the script.
- // - Added optional Currency labels at end of Currency strenth line.
- //
- // 10-Nov-2017 by JustUncleL
- // - Corrected the weighting on JPY pairs, divide the close values by 100 to
- // bring them within 1.0 range of the pairs.
- // - Added option to use different Data Source, eg hl2, hlc3, ohlc4 etc.
- // - Updated to PineScript version 3.
- //
- // -----------------------------------------------------------------------------
- // Copyright 2015 Glaz
- // Copyright 2017 JustUncleL
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // The GNU General Public License can be found here
- // <http://www.gnu.org/licenses/>.
- //
- // -----------------------------------------------------------------------------
- // === INPUTS ===
- fast= input(10,minval=1,maxval=150)
- slow= input(40,minval=2,maxval=300)
- src = input(close,title="Source")
- uWghts = input(true,title="Use ATR weighted Averages in Strength Calculation")
- ShowLabels = input(true)
- ShowFixed = input(true,title="Show labels as a Fixed List, instead of Strength following")
- // === /INPUTS ===
- // === SERIES ===
- // Current source values
- audcad = security("FX_IDC:AUDCAD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- audchf = security("FX_IDC:AUDCHF", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- audjpy = security("FX_IDC:AUDJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- audnzd = security("FX_IDC:AUDNZD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- audusd = security("FX_IDC:AUDUSD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- //
- cadchf = security("FX_IDC:CADCHF", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- cadjpy = security("FX_IDC:CADJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- //
- chfjpy = security("FX_IDC:CHFJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- //
- euraud = security("FX_IDC:EURAUD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- eurcad = security("FX_IDC:EURCAD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- eurchf = security("FX_IDC:EURCHF", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- eurgbp = security("FX_IDC:EURGBP", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- eurjpy = security("FX_IDC:EURJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- eurnzd = security("FX_IDC:EURNZD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- eurusd = security("FX_IDC:EURUSD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- //
- gbpaud = security("FX_IDC:GBPAUD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- gbpcad = security("FX_IDC:GBPCAD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- gbpchf = security("FX_IDC:GBPCHF", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- gbpjpy = security("FX_IDC:GBPJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- gbpnzd = security("FX_IDC:GBPNZD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- gbpusd = security("FX_IDC:GBPUSD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- //
- nzdcad = security("FX_IDC:NZDCAD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- nzdchf = security("FX_IDC:NZDCHF", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- nzdjpy = security("FX_IDC:NZDJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- nzdusd = security("FX_IDC:NZDUSD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- //
- usdcad = security("FX_IDC:USDCAD", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- usdchf = security("FX_IDC:USDCHF", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- usdjpy = security("FX_IDC:USDJPY", period, src/100, barmerge.gaps_off, barmerge.lookahead_on)
- //
- eurzar = security("FX_IDC:EURZAR", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- gbpzar = security("FX_IDC:GBPZAR", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- usdzar = security("FX_IDC:USDZAR", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- //
- eurtry = security("FX_IDC:EURTRY", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- usdtry = security("FX_IDC:USDTRY", period, src, barmerge.gaps_off, barmerge.lookahead_on)
- // Estimate Currency Strength based on the Average Influence Rates
- // Scaling factor
- sf = uWghts? 14.29 : 0.1429
- //Calculate Currency strength ATR weighted (default) or no weighting.
- EUR = uWghts? (eurusd/80 + eurgbp/75 + euraud/125 + eurjpy/105 + eurcad/120 + eurchf/50 + eurnzd/135)*sf :
- (eurusd + eurgbp + euraud + eurjpy + eurcad + eurchf + eurnzd)*sf
- USD = uWghts? (usdjpy/100 + usdcad/90 + usdchf/70 - audusd/60 - gbpusd/120 - eurusd/80 - nzdusd/65)*sf :
- (usdjpy + usdcad + usdchf - audusd - gbpusd - eurusd - nzdusd)*sf
- JPY = uWghts? -(audjpy/85 + cadjpy/60 + chfjpy/90 + eurjpy/105 + gbpjpy/160 + usdjpy/100 + nzdjpy/80)*sf :
- -(audjpy + cadjpy + chfjpy + eurjpy + gbpjpy + usdjpy + nzdjpy)*sf
- GBP = uWghts? (gbpjpy/160 + gbpcad/160 + gbpchf/110 - eurgbp/75 + gbpusd/120 + gbpaud/170 + gbpnzd/200)*sf :
- (gbpjpy + gbpcad + gbpchf - eurgbp + gbpusd + gbpaud + gbpnzd)*sf
- AUD = uWghts? (audjpy/85 + audcad/75 + audchf/70 - euraud/125 - gbpaud/160 + audusd/60 + audnzd/70)*sf :
- (audjpy + audcad + audchf - euraud - gbpaud + audusd + audnzd)*sf
- CAD = uWghts? (cadjpy/90 + cadchf/60 - audcad/75 - eurcad/120 - gbpcad/160 - usdcad/90 - nzdcad/80)*sf :
- (cadjpy + cadchf - audcad - eurcad - gbpcad - usdcad - nzdcad)*sf
- CHF = uWghts? (chfjpy/90 - cadchf/60 - audchf/70 - eurchf/50 - gbpchf/110 - usdchf/70 - nzdchf/65)*sf :
- (chfjpy - cadchf - audchf - eurchf - gbpchf - usdchf - nzdchf)*sf
- NZD = uWghts? (nzdjpy/80 + nzdchf/65 + nzdcad/80 + nzdusd/65 - gbpnzd/200 - eurnzd/135 - audnzd/70)*sf :
- (nzdjpy + nzdchf + nzdcad + nzdusd - gbpnzd - eurnzd - audnzd)*sf
- // Exotics
- ZAR = uWghts? (-eurzar/220 - gbpzar/265 - usdzar/1960)*sf : (-eurzar - gbpzar - usdzar)*sf
- TRY = uWghts? (-eurtry/520 - usdtry/420)*sf : (-eurtry - usdtry)*sf
- // Use True Strength Index, to calculate Currency Strength.
- eur=tsi(EUR,fast,slow)
- gbp=tsi(GBP,fast,slow)
- jpy=tsi(JPY,fast,slow)
- usd=tsi(USD,fast,slow)
- aud=tsi(AUD,fast,slow)
- cad=tsi(CAD,fast,slow)
- chf=tsi(CHF,fast,slow)
- nzd=tsi(NZD,fast,slow)
- try=tsi(TRY,fast,slow)
- zar=tsi(ZAR,fast,slow)
- // === /SERIES ===
- // === PLOTTING ===
- // Plot Strength on chart
- plot(aud,color=blue,title='AUD',linewidth=2,transp=0,join=true)
- plot(cad,color=fuchsia,title='CAD',linewidth=2,transp=0,join=true)
- plot(chf,color=black,title='CHF',linewidth=2,transp=0,join=true)
- plot(eur,color=orange,title='EUR',linewidth=2,transp=0,join=true)
- plot(gbp,color=teal,title='GBP',linewidth=2,transp=0,join=true)
- plot(jpy,color=red,title='JPY',linewidth=2,transp=0,join=true)
- plot(nzd,color=aqua,title='NZD',linewidth=2,transp=0,join=true)
- plot(usd,color=green,title='USD',linewidth=2,transp=0,join=true)
- plot(try,color=gray,title='TRY',linewidth=2,transp=0,join=true)
- plot(zar,color=purple,title='ZAR',linewidth=2,transp=0,join=true)
- hline(0,"Zero",color=navy,linestyle=dotted,linewidth=2)
- hline(0.5,"Upper Line",color=gray,linestyle=dashed,linewidth=1)
- hline(-0.5,"Lower Line",color=gray,linestyle=dashed,linewidth=1)
- //
- Fixed = ShowFixed and ShowLabels and barstate.islast
- plotshape(Fixed?0.525:na,location=location.absolute,style=shape.labeldown,title="TRY txt",
- color=gray,text="TRY",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?0.400:na,location=location.absolute,style=shape.labeldown,title="AUD txt",
- color=blue,text="AUD",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?0.275:na,location=location.absolute,style=shape.labeldown,title="CAD txt",
- color=fuchsia,text="CAD",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?0.150:na,location=location.absolute,style=shape.labeldown,title="CHF txt",
- color=black,text="CHF",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?0.025:na,location=location.absolute,style=shape.labeldown,title="EUR txt",
- color=orange,text="EUR",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?-0.025:na,location=location.absolute,style=shape.labelup,title="GBP txt",
- color=teal,text="GBP",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?-0.150:na,location=location.absolute,style=shape.labelup,title="JPY txt",
- color=red,text="JPY",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?-0.275:na,location=location.absolute,style=shape.labelup,title="NZD txt",
- color=aqua,text="NZD",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?-0.400:na,location=location.absolute,style=shape.labelup,title="USD txt",
- color=green,text="USD",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- plotshape(Fixed?-0.525:na,location=location.absolute,style=shape.labelup,title="ZAR txt",
- color=purple,text="ZAR",textcolor=white,show_last=1,transp=0,offset=5,size=size.auto)
- //
- Dynamic = not ShowFixed and ShowLabels and barstate.islast
- plotshape(Dynamic?aud:na,location=location.absolute,style=shape.labeldown,title="AUD d.txt",
- color=blue,text="AUD",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?cad:na,location=location.absolute,style=shape.labeldown,title="CAD d.txt",
- color=fuchsia,text="CAD",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?chf:na,location=location.absolute,style=shape.labeldown,title="CHF d.txt",
- color=black,text="CHF",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?eur:na,location=location.absolute,style=shape.labeldown,title="EUR d.txt",
- color=orange,text="EUR",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?gbp:na,location=location.absolute,style=shape.labeldown,title="GBP d.txt",
- color=teal,text="GBP",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?jpy:na,location=location.absolute,style=shape.labeldown,title="JPY d.txt",
- color=red,text="JPY",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?nzd:na,location=location.absolute,style=shape.labeldown,title="NZD d.txt",
- color=aqua,text="NZD",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?usd:na,location=location.absolute,style=shape.labeldown,title="USD d.txt",
- color=green,text="USD",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?usd:na,location=location.absolute,style=shape.labeldown,title="TRY d.txt",
- color=gray,text="TRY",textcolor=white,show_last=1,transp=0,offset=2)
- plotshape(Dynamic?usd:na,location=location.absolute,style=shape.labeldown,title="ZAR d.txt",
- color=purple,text="ZAR",textcolor=white,show_last=1,transp=0,offset=2)
- // === /PLOTTING ===
- //eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement