AEParticipant
Senior
Hi folks!
I would like to know if there is any way to set a price to buy using the last positionprice of my last operation.
Example:
Step 1. Strategy condition is met and buy DAX at 13.200. Set TP at 13.230
Step 2. DAX move up to 13.230 so it closed the position
Step 3. Create a new order limit to buy at last positionprice (13.200)
Thanks
Yes use TRADEPRICE(1)
https://www.prorealcode.com/documentation/tradeprice/
However, reading the link above confused me a bit … to use your example …
IS
TRADEPRICE(1) = 13.230 (exit order)
AND
TRADEPRICE(2) = 13.200 (entry order)
I’m sure some helpful member will spot this post and clarify for us?
Yes TRADEPRICE is the last order price (or last Nth order price) so if the last order was an exit that is what TRADEPRICE will be so this does not work for position price.
You need to record POSITIONPRICE at the close of each bar.
if onmarket then
lastprice = positionprice
endif
Then you can buy at that price using a pending order.