Hi,
I am trying to code an auto-traded strategy but would need some “basic” help to complete it as I am still new to the programming – so straight to the Questions:
- Q1 – Exit: In the auto trading function you will by default exit at market price, next bar open. I rather want to exit at current bar 5 minutes before closing. How to code that?
- Q2 – Entry: By default, you enter at market price, next bar open. I rather want to enter next bar open IF e.g. +0.2% above prev candle high. How to code that?
- Q3 – Profit: At previous structure high (looking e.g. 20 days back). How to code that?
Many thanks in advance! Examples are appreciated too.
Lasse
Please find below answers to your 3 questions:
1/ Not possible until the multi-timeframe is available in the coding languag
2/ You need to place on market a pending STOP order at current high price * 0.002 , it will only last 1 candlestick:
BUY 1 SHARE AT high*1.002 STOP
3/ First define the profit in points between the 20 days back highest high and the current close (price when the calculation will be made):
takeprofit = highest[20](high)[1]-close
then set your takeprofit in your code with this instruction:
SET TARGET PROFIT takeprofit