How can I create order in Pine Script with specific settings according to current price

Viewed 28

It's kind of super simple task I guess, but I don't know how to do it yet.

I want to add a button on the graph which takes the current price and place an order with specific values based on that price.

Each help is much appreciated.

1 Answers

Use input.price() function to determine variable that will be used for strategy.entry() condition.

e.g.

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

price = input.price(0, confirm =  true)

if close > price*1.2 
    strategy.entry("My Long Entry Id", strategy.long)

Related