Search code examples
labelcopypine-script

Copying label to another time frame


How can I copy a label from one time frame to another?

This is the code I use to copy the label within the same time frame:

label_name_x = label.get_x(label_name)  
label_name_y = label.get_y(label_name)  
new_label_name = label.new(label_name_x[1],label_name_y[1],text=str.tostring(text_label_name))  

Using request.security() in the new time frame does not seem to work as I cannot define the variables/parameters in the new time frame but have to use the ones from the original time frame.


Solution

  • You cannot directly copy a label to another timeframe.

    You need to figure out the condition that creates the label and look for that condition on another timeframe. Then create the label if that condition is true on the other timeframe. You should do some calculations to find out its x position but that depends on your use case.