Hide trades on chart, quantity and signal labels in code tradingview

Viewed 2495

I am looking for a way to hide: trades on the chart, quantity, and signal labels -

When using a pinescript strategy for trading view.

I want to do this in the code and not in the settings window. At the moment I have to uncheck the boxes every time I make a change to the script and I can't find the setting in the code or extra code to make this happen.

To uncheck the boxes each time I make a change in the script is....mweh...

Hopefully, someone can help me out with this seemingly simple issue. I have already spent quite a bit of time to figure this out...but no luck so far.

2 Answers

I believe I understand what you are trying to achieve.

So if you create an input and set it as false:

UnHideCode = input(false, title="Un Hide Code", type=input.bool)

Then apply this as an "and" to the signal labels (etc) you don't want to untick all the time.

if(LongSignal and UnHideCode)
    strategy.entry("Buy - Long Term", long=true)

As the UnHideCode is set to false it should not display, to make them all display you would then go into the setting and tick the Un Hide Code box.

According to the documentation, when you define a strategy, you can't set the default comment:

strategy(title, shorttitle, overlay, format, precision, scale, pyramiding, 
calc_on_order_fills, calc_on_every_tick, max_bars_back, backtest_fill_limits_assumption, default_qty_type,  
default_qty_value, initial_capital, currency, max_lines_count, 
max_labels_count, slippage, commission_type, commission_value, process_orders_on_close, 
close_entries_rule, margin_long, margin_short, max_boxes_count, explicit_plot_zorder) → void

so, the best workaround is override into the order with a space string in the comment:

strategy.entry("OverSelled", strategy.long, when = OVERSELLED_LONG, comment =' ' )
strategy.close("OverSelled",when=OVERSELLED_CLOSE,comment =' ')

NOTE: the quantities will remain in the chart

Related