Skip to content

Commit 248ed20

Browse files
Merge pull request #31 from AlbertoCuadra/develop
Update: basic alarm system
2 parents 14b1cbb + 0894d00 commit 248ed20

1 file changed

Lines changed: 28 additions & 23 deletions

File tree

weighted_strategy.pine

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ long_trail_perc = input.float(150, 'Trail volume Long (%)', minval=0.0, step=1,
103103
short_trail_perc = input.float(150, 'Trail volume Short (%)', minval=0.0, step=1, group='Potential TOP/BOTTOM') * 0.01
104104
// * Miscellaneous
105105
show_signals = input.bool(true, 'Show Buy/Sell Signals ?', group='Miscellaneous')
106-
107-
106+
// * Alarms
107+
alarm_label_long = input.string('Buy', 'Label open long', group='Basic alarm system')
108+
alarm_label_short = input.string('Sell', 'Label open short', group='Basic alarm system')
109+
alarm_label_close_long = input.string('Close long', 'Label close long', group='Basic alarm system')
110+
alarm_label_close_short = input.string('Close short', 'Label close short', group='Basic alarm system')
111+
alarm_label_TP = input.string('TP', 'Label Take Profit', group='Basic alarm system')
112+
alarm_label_SL = input.string('SL', 'Label Stop-Loss', group='Basic alarm system')
108113
// *************************************************************************************************************************************************************************************************************************************************************************
109114
// ABBREVIATIONS
110115
// *************************************************************************************************************************************************************************************************************************************************************************
@@ -345,41 +350,41 @@ if time >= start and time <= end
345350
if allow_shorts == true
346351
w_total = weight_total(short_signal1, short_signal2, short_signal3, short_signal4, short_signal5)
347352
if w_total >= weight_trigger
348-
strategy.entry('Short', strategy.short, alert_message='Sell')
353+
strategy.entry('Short', strategy.short, alert_message=alarm_label_short)
349354
if allow_longs == true
350355
w_total = weight_total(long_signal1, long_signal2, long_signal3, long_signal4, long_signal5)
351356
if w_total >= weight_trigger
352-
strategy.entry('Long', strategy.long, alert_message='Buy')
357+
strategy.entry('Long', strategy.long, alert_message=alarm_label_long)
353358
else
354359
if allow_shorts == true
355360
if str_1
356-
strategy.entry('Short', strategy.short, when=short_signal1, alert_message='Sell')
361+
strategy.entry('Short', strategy.short, when=short_signal1, alert_message=alarm_label_short)
357362
if str_2
358-
strategy.entry('Short', strategy.short, when=short_signal2, alert_message='Sell')
363+
strategy.entry('Short', strategy.short, when=short_signal2, alert_message=alarm_label_short)
359364
if str_3
360-
strategy.entry('Short', strategy.short, when=short_signal3, alert_message='Sell')
365+
strategy.entry('Short', strategy.short, when=short_signal3, alert_message=alarm_label_short)
361366
if str_4
362-
strategy.entry('Short', strategy.short, when=short_signal4, alert_message='Sell')
367+
strategy.entry('Short', strategy.short, when=short_signal4, alert_message=alarm_label_short)
363368
if str_5
364-
strategy.entry('Short', strategy.short, when=short_signal5, alert_message='Sell')
369+
strategy.entry('Short', strategy.short, when=short_signal5, alert_message=alarm_label_short)
365370
if allow_longs == true
366371
if str_1
367-
strategy.entry('Long', strategy.long, when=long_signal1, alert_message='Buy')
372+
strategy.entry('Long', strategy.long, when=long_signal1, alert_message=alarm_label_long)
368373
if str_2
369-
strategy.entry('Long', strategy.long, when=long_signal2, alert_message='Buy')
374+
strategy.entry('Long', strategy.long, when=long_signal2, alert_message=alarm_label_long)
370375
if str_3
371-
strategy.entry('Long', strategy.long, when=long_signal3, alert_message='Buy')
376+
strategy.entry('Long', strategy.long, when=long_signal3, alert_message=alarm_label_long)
372377
if str_4
373-
strategy.entry('Long', strategy.long, when=long_signal4, alert_message='Buy')
378+
strategy.entry('Long', strategy.long, when=long_signal4, alert_message=alarm_label_long)
374379
if str_5
375-
strategy.entry('Long', strategy.long, when=long_signal5, alert_message='Buy')
380+
strategy.entry('Long', strategy.long, when=long_signal5, alert_message=alarm_label_long)
376381
// ***************************************************************************************************************************************************************************
377382
// * Set Take Profits
378383
// ***************************************************************************************************************************************************************************
379384
if strategy.position_size != 0 and take_profits and since_entry == 0
380385
for i = 1 to MAX_TP
381386
id = 'TP ' + str.tostring(i)
382-
strategy.exit(id=id, limit=price_takeProfit(profit_perc, i), qty_percent=profit_qty, comment=id, alert_message='TP')
387+
strategy.exit(id=id, limit=price_takeProfit(profit_perc, i), qty_percent=profit_qty, comment=id, alert_message=alarm_label_TP)
383388
// ***************************************************************************************************************************************************************************
384389
// * Set Stop loss
385390
// ***************************************************************************************************************************************************************************
@@ -531,23 +536,23 @@ if time >= start and time <= end
531536
// * Set Exits
532537
// ***************************************************************************************************************************************************************************
533538
if allow_longs == true and allow_shorts == false
534-
strategy.close('Long', when=close_long1 or close_long5, qty_percent=100, comment='LONG', alert_message='Close long')
539+
strategy.close('Long', when=close_long1 or close_long5, qty_percent=100, comment='LONG', alert_message=alarm_label_close_long)
535540
if allow_longs == false and allow_shorts == true
536-
strategy.close('Short', when=close_short1 or close_short5, qty_percent=100, comment='SHORT', alert_message='Close long')
541+
strategy.close('Short', when=close_short1 or close_short5, qty_percent=100, comment='SHORT', alert_message=alarm_label_close_long)
537542
if allow_shorts == true and strategy.position_size < 0 and stoploss and since_entry > 0
538-
strategy.close('Short', when=stop_source >= price_stop_short, qty_percent=100, comment='STOP', alert_message='Close short')
543+
strategy.close('Short', when=stop_source >= price_stop_short, qty_percent=100, comment='STOP', alert_message=alarm_label_close_short)
539544
if str_6
540545
if top_qty == 100
541-
strategy.close('Short', when=condition_OS_several, qty_percent=bottom_qty, comment='STOP', alert_message='Close short')
546+
strategy.close('Short', when=condition_OS_several, qty_percent=bottom_qty, comment='STOP', alert_message=alarm_label_close_short)
542547
else
543-
strategy.exit('Short', when=condition_OS_several, limit=source_6_bottom[1], qty_percent=bottom_qty, comment='TP-B', alert_message='TP')
548+
strategy.exit('Short', when=condition_OS_several, limit=source_6_bottom[1], qty_percent=bottom_qty, comment='TP-B', alert_message=alarm_label_TP)
544549
if allow_longs == true and strategy.position_size > 0 and stoploss and since_entry > 0
545-
strategy.close('Long', when=stop_source <= price_stop_long, qty_percent=100, comment='STOP', alert_message='Stop')
550+
strategy.close('Long', when=stop_source <= price_stop_long, qty_percent=100, comment='STOP', alert_message=alarm_label_SL)
546551
if str_6
547552
if top_qty == 100
548-
strategy.close('Long', when=condition_OB_several, qty_percent=top_qty, comment='STOP', alert_message='Stop')
553+
strategy.close('Long', when=condition_OB_several, qty_percent=top_qty, comment='STOP', alert_message=alarm_label_SL)
549554
else
550-
strategy.exit('Long', when=condition_OB_several, limit=source_6_top[1], qty_percent=top_qty, comment='TP-T', alert_message='TP')
555+
strategy.exit('Long', when=condition_OB_several, limit=source_6_top[1], qty_percent=top_qty, comment='TP-T', alert_message=alarm_label_TP)
551556
// *************************************************************************************************************************************************************************************************************************************************************************
552557
// * Data window - debugging
553558
// *************************************************************************************************************************************************************************************************************************************************************************

0 commit comments

Comments
 (0)