1
votes

can someone enlighten me, please.

On the code below, Does the input line default to "1" or does the "step" argument change the result (to decimal)? in the end what is the result?

long_tp_inp = input(100, title="Long Take Profit %", step=0.1) / 100 //what does step ?

Then what is the result of the command below: strategy.position_avg_price * (1 + long_tp_inp)

thank for help

1

1 Answers

0
votes

It is percentage of the initial strategy.position_avg_price.

If long_tp_inp is 100, then your strategy.position_avg_price * (1 + 100/100) = strategy.position_avg_price*2, so your exit/entry will be at price higher by 100% of the current price.

Example:

//@version=4
strategy("My Strategy", overlay=true, margin_long=100, margin_short=100)


long_tp_inp = input(100, title="Long Take Profit %", step=0.1) / 100 
price = strategy.position_avg_price * (1 + long_tp_inp)    
plot(price)


if bar_index == 1
    strategy.entry ("LONG", true)
    
strategy.exit("EXIT", "LONG", limit =   price)