0

I am trying to do something very basic in Pine, but I am completely stumped on how to solve the issue. In summary I have an alert which need to update a fixed price level on a user input. The alert places an order on the chart, and I can update the price level as I see fit. When the alert is re-triggered (once per bar close) then the order is placed at the new level

However, the only behaviour I can see is that the initial variable is forever fixed until I remove the alert completely from the alert console and re-add the alert. For example, if I apply the below alert to the chart the fp=0 will not change even though I change the user input after the alert has been added.

Any help is much appreciated. Or if you need more info please let me know. Thanks in advance

var symbol = syminfo.basecurrency + "/" + syminfo.currency
var avPrefix = "e=oandapractice "  + " s=" + symbol + ""
var TpPrice = 0.000000
t_TpPrice = input(title="TP Price?", type=input.float,  defval=0.000000, step=0.000001)


if (barstate.isrealtime) 
    TpPrice := t_TpPrice
    clearOrder = avPrefix + " c=order\n "
    tpTrigger = avPrefix + " b=sell" + " q=20000" + " t=limit" + " fp=" + tostring(TpPrice)
    alert( message=clearOrder + tpTrigger ,freq=alert.freq_once_per_bar_close)   
Barney
  • 13
  • 3

1 Answers1

0

You are using input constant variable, which is not changes after compilation. You will need to recreate alert, if you want to use it with another value from input.

Starr Lucky
  • 1,578
  • 1
  • 7
  • 8
  • Yes, I understand that is what's happening. Specifically My question is, is there a feature or function which will allow a change of this variable after the alert has been created? Or is there another way which the script could be written to enact the same outcome? Thanks – Barney Sep 17 '21 at 14:08
  • Unfortunately no. – Starr Lucky Sep 20 '21 at 12:12