Tradingview, pinescript strategy.comment, multiple comments

Viewed 17

I do have a specific tradingview, pinescript command structure I want to maintain, and this includes strategy related arguments as well.

(since I know matlab, I will start with this). In matlab nomenclature, if you have a string array, you can do the following

array = ['dog'; 'cat']

and you can call

array(1) (to display 'dog', or array(2) to display 'cat' ...etc. And if you want to assign it to a new variable, you can do it as

new = array(1); %etc.....

In pinescript what I am trying to do is the following

orderCondition = array.new_string(4)
array.insert(orderCondition, 1, 'open') 
array.insert(orderCondition, 2, 'open_new') 

array.insert(orderCondition, 3, 'close') 
array.insert(orderCondition, 4, 'close_old')   

So in this array I am hoping I have something like

[ 'open'; 'open_new'; 'close'; 'close_old' ]

The critical part is in the assignment section. What I want to achieve is the following. I want to declare the first two parts of the array in one strategy comment, and the remaining two in the other, like

strategy.entry("LE", strategy.long, comment=orderCondition[1,2])


strategy.entry("LE", strategy.long, comment=orderCondition[3,4])

so that I group them. And not only that I am also hoping to be able to read those in strategy alert window, as

{{strategy.comment[1-2]}}

{{strategy.comment[3-4]}}

Is this possible? And if possible how can I achieve this? Thank you for your time.

0 Answers
Related