Skip to content

Commit b4ee0e7

Browse files
Merge pull request #54 from AlbertoCuadra/develop
Add: flag show shadows
2 parents 78a44c7 + 6c143c8 commit b4ee0e7

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

weighted_strategy.pine

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// *************************************************************************************************************************************************************************************************************************************************************************
2-
// Acrypto - Weigthed Strategy v1.4.7
2+
// Acrypto - Weigthed Strategy v1.4.8
33
// Github: https://github.com/AlbertoCuadra/algo_trading_weighted_strategy
44
//
55
//
@@ -8,10 +8,10 @@
88
// License: © accry - This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
99
// https://creativecommons.org/licenses/by-nc-sa/4.0/
1010
//
11-
// Last update: 13/04/2022
11+
// Last update: 23/04/2022
1212
// *************************************************************************************************************************************************************************************************************************************************************************
1313
//@version=5
14-
strategy(title='Acrypto - Weighted Strategy v1.4.7', overlay=true, precision=2, commission_value=0.075, commission_type=strategy.commission.percent, initial_capital=1000, currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=100, slippage=1)
14+
strategy(title='Acrypto - Weighted Strategy v1.4.8', overlay=true, precision=2, commission_value=0.075, commission_type=strategy.commission.percent, initial_capital=1000, currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=100, slippage=1)
1515
// *************************************************************************************************************************************************************************************************************************************************************************
1616
// COMMENTS
1717
// *************************************************************************************************************************************************************************************************************************************************************************
@@ -101,8 +101,9 @@ source_6_top = input.source(close, 'TP-TOP at previous?', group='Potential TOP/B
101101
source_6_bottom = input.source(close, 'TP-BOTTOM at previous?', group='Potential TOP/BOTTOM')
102102
long_trail_perc = input.float(150, 'Trail volume Long (%)', minval=0.0, step=1, group='Potential TOP/BOTTOM') * 0.01
103103
short_trail_perc = input.float(150, 'Trail volume Short (%)', minval=0.0, step=1, group='Potential TOP/BOTTOM') * 0.01
104-
// * Miscellaneous
105-
show_signals = input.bool(true, 'Show Buy/Sell Signals ?', group='Miscellaneous')
104+
// * Flags
105+
FLAG_SIGNALS = input.bool(true, 'Show Buy/Sell Signals ?', group='Miscellaneous')
106+
FLAG_SHADOWS = input.bool(true, 'Show shadows satisfied strategies ?', group='Miscellaneous')
106107
// * Alarms
107108
alarm_label_long = input.string('Buy', 'Label open long', group='Basic alarm system')
108109
alarm_label_short = input.string('Sell', 'Label open short', group='Basic alarm system')
@@ -621,28 +622,28 @@ plotchar(strategy.wintrades/strategy.closedtrades*100, "Winrate [%]", "", locati
621622
plot(trend, 'Trend', style=plot.style_columns, color=MACD > signal ? color.new(color.teal, 30) : color.new(color.gray, 30), display=display.none)
622623
plot(MACD, 'MACD', color=color.new(color.blue, 0), display=display.none)
623624
plot(signal, 'Signal', color=color.new(color.orange, 0), display=display.none)
624-
plotshape(long_signal1 and show_signals ? up : na, 'Buy MACD', text='MACD', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
625-
plotshape(short_signal1 and show_signals ? dn : na, 'Sell MACD', text='MACD', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
625+
plotshape(long_signal1 and FLAG_SIGNALS ? up : na, 'Buy MACD', text='MACD', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
626+
plotshape(short_signal1 and FLAG_SIGNALS ? dn : na, 'Sell MACD', text='MACD', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
626627
// *************************************************************************************************************************************************************************************************************************************************************************
627628
// * strategy 2: Stoch RSI
628629
// *************************************************************************************************************************************************************************************************************************************************************************
629-
plotshape(long_signal2 and show_signals ? up : na, title='Buy Stoch RSI', text='SRSI', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
630-
plotshape(short_signal2 and show_signals ? dn : na, title='Sell Stoch RSI', text='SRSI', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
630+
plotshape(long_signal2 and FLAG_SIGNALS ? up : na, title='Buy Stoch RSI', text='SRSI', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
631+
plotshape(short_signal2 and FLAG_SIGNALS ? dn : na, title='Sell Stoch RSI', text='SRSI', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
631632
// *************************************************************************************************************************************************************************************************************************************************************************
632633
// * strategy 3: RSI
633634
// *************************************************************************************************************************************************************************************************************************************************************************
634-
plotshape(long_signal3 and show_signals ? up : na, title='Buy RSI', text='RSI', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
635-
plotshape(short_signal3 and show_signals ? dn : na, title='Sell RSI', text='RSI', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
635+
plotshape(long_signal3 and FLAG_SIGNALS ? up : na, title='Buy RSI', text='RSI', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
636+
plotshape(short_signal3 and FLAG_SIGNALS ? dn : na, title='Sell RSI', text='RSI', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
636637
// *************************************************************************************************************************************************************************************************************************************************************************
637638
// * strategy 4: Supertrend
638639
// *************************************************************************************************************************************************************************************************************************************************************************
639-
plotshape(long_signal4 and show_signals ? up : na, title='Buy Supertrend', text='Supertrend', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
640-
plotshape(short_signal4 and show_signals ? dn : na, title='Sell Supertrend', text='Supertrend', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
640+
plotshape(long_signal4 and FLAG_SIGNALS ? up : na, title='Buy Supertrend', text='Supertrend', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
641+
plotshape(short_signal4 and FLAG_SIGNALS ? dn : na, title='Sell Supertrend', text='Supertrend', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
641642
// *************************************************************************************************************************************************************************************************************************************************************************
642643
// * strategy 5: MA CROSS
643644
// *************************************************************************************************************************************************************************************************************************************************************************
644-
plotshape(long_signal5 and show_signals ? up : na, title='Buy MA CROSS', text='MA CROSS', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
645-
plotshape(short_signal5 and show_signals ? dn : na, title='Sell MA CROSS', text='MA CROSS', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
645+
plotshape(long_signal5 and FLAG_SIGNALS ? up : na, title='Buy MA CROSS', text='MA CROSS', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0), display=display.none)
646+
plotshape(short_signal5 and FLAG_SIGNALS ? dn : na, title='Sell MA CROSS', text='MA CROSS', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0), display=display.none)
646647
// *************************************************************************************************************************************************************************************************************************************************************************
647648
// * STRATEGY 6: POTENTIAL TOP/BOTTOM
648649
// *************************************************************************************************************************************************************************************************************************************************************************
@@ -653,8 +654,8 @@ plotshape(condition_OS_several ? up : na, title='Bottom', text='B', location=loc
653654
// *************************************************************************************************************************************************************************************************************************************************************************
654655
w_total_long = weight_total(long_signal1, long_signal2, long_signal3, long_signal4, long_signal5)
655656
w_total_short = weight_total(short_signal1, short_signal2, short_signal3, short_signal4, short_signal5)
656-
plotshape(w_total_long >= weight_trigger and show_signals ? up : na, title='Buy Weigthed strategy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0))
657-
plotshape(w_total_short >= weight_trigger and show_signals ? dn : na, title='Sell Weigthed strategy', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0))
657+
plotshape(w_total_long >= weight_trigger and FLAG_SIGNALS ? up : na, title='Buy Weigthed strategy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.teal, 0), textcolor=color.new(color.white, 0))
658+
plotshape(w_total_short >= weight_trigger and FLAG_SIGNALS ? dn : na, title='Sell Weigthed strategy', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.gray, 0), textcolor=color.new(color.white, 0))
658659
// *************************************************************************************************************************************************************************************************************************************************************************
659660
// * Stop loss targets
660661
// *************************************************************************************************************************************************************************************************************************************************************************
@@ -675,8 +676,8 @@ plotchar(w_total_long, "Satisfied Long strategies", "", location.top, size = siz
675676
plotchar(w_total_short, "Satisfied Short strategies", "", location.top, size = size.tiny, color=w_total_long >= weight_trigger ? color.orange : color.gray)
676677
plotshape((long_signal1 or long_signal2 or long_signal3 or long_signal4 or long_signal5) and (w_total_long > w_total_short) ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.aqua, 0), display=display.none)
677678
plotshape((short_signal1 or short_signal2 or short_signal3 or short_signal4 or short_signal5) and (w_total_short > w_total_long) ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.gray, 0), display=display.none)
678-
fill(mPlot, upPlot, title='UpTrend Highligter', color=colors('buy', 80))
679-
fill(mPlot, dnPlot, title='DownTrend Highligter', color=colors('sell', 80))
679+
fill(mPlot, upPlot, title='UpTrend Highligter', color=colors('buy', FLAG_SHADOWS ? 80:100))
680+
fill(mPlot, dnPlot, title='DownTrend Highligter', color=colors('sell', FLAG_SHADOWS ? 80:100))
680681
// *************************************************************************************************************************************************************************************************************************************************************************
681682
// MONTHLY TABLE PERFORMANCE - Developed by @QuantNomad
682683
// *************************************************************************************************************************************************************************************************************************************************************************

0 commit comments

Comments
 (0)