How to automate partial close based on percentage profit target
Posted: Fri Aug 19, 2022 2:29 pm
Hi All,
I trade Forex using TradingView with Forex.com as my broker.
I've been searching the internet and even wrote to TradingView support but I can't seem to get a straight answer on what I wish to do:
For example, say I have 2000 units (2 micro lots) and I want to automatically close 1000 units (1 micro lot) at 40% of take profit target and then close the next 1000 units at 80% take profit target.
Is this possible to do in principle via Pine script in TradingView? I have never heard of Pine until I started Googling what I am trying to accomplish above
Thanks
-PS I'm versed in SQL/Python/VBA
I've found something here that looks promising:
https://www.tradingcode.net/tradingview ... -function/
This looks like something that could work. Either I could use it if price hits a certain alert or certain percentage profit target then sell x quantity divided by 2 for example.
I'm I way off or on the right track?
I trade Forex using TradingView with Forex.com as my broker.
I've been searching the internet and even wrote to TradingView support but I can't seem to get a straight answer on what I wish to do:
For example, say I have 2000 units (2 micro lots) and I want to automatically close 1000 units (1 micro lot) at 40% of take profit target and then close the next 1000 units at 80% take profit target.
Is this possible to do in principle via Pine script in TradingView? I have never heard of Pine until I started Googling what I am trying to accomplish above
Thanks
-PS I'm versed in SQL/Python/VBA
I've found something here that looks promising:
https://www.tradingcode.net/tradingview ... -function/
This looks like something that could work. Either I could use it if price hits a certain alert or certain percentage profit target then sell x quantity divided by 2 for example.
I'm I way off or on the right track?
Code: Select all
// When prices drop below the 20-bar lowest low, submit a sell order
if low < ta.lowest(low, 20)[1]
strategy.order("Sell (Market)", strategy.short, qty=20)