I want to write a pinescript strategy that places a simultaneous buy and sell order at the open price of each candle on my selected chart. The buy and sell orders have TP of ATR value/3. And they both have SL of the ATR value. The results from ChatGPT and Bard are error prone as usual and don’t work in the pinescript editor.
This GPT is specific for writing Pinescript code: https://www.pinescriptwizard.com/ Have you tried it?
I don't understand your request. What do you mean place buy AND sell orders at open price? You mean you want to execute market order when new candle opens?
Yeah I know. Just want to know how many times the TP is executed more than the stop loss. When the SL is 3 time greater than the TP. And to try it both directions. And also if neither is touched before the end of the closing day, then the close price is exit for both the buy and sell market orders.
If your stop loss is higher than the TP and you do it both directions simultaneously then how can stop loss ever be touched before first TP? Or you mean that when the first TP is executed you will open another position at the open price should the price trade back there and then have a new at 0.3ATR again? So, basically you want to know how much price ranges before back and forth 0.3ATR before reaching first SL?
Exactly. Want to know how much price ranges. How often does it go back and forth before trending for a long time in one direction(and hitting the SL). I am not interested in the trades PNL values. Just want to count the number of TP hit instead of SL