Hi Everyone,
I’m trying to achieve something I believe is very simple but I am having a few troubles. What I would like is an average exit price of different entry prices and quantities when I set accumulate to true but cant seem to get it to work as expected. After reading as much as possible it seems profit target is meant to do this but it doesnt. I have tried using other commands in code such as positionprice but with no success. Any help would be great.
Many Thanks
Carter
Hi,
Do you mean you need to set an exit price for the whole basket in relation to their mean open price?
POSITIONPRICE give you the average open price of the whole open orders. If you need to exit them at 5 points from it, you have to set a STOP or a LIMIT order at that price.
Hi Nicolas,
Thank you for your reply, please see some code below for example. I’m not sure of the correct syntax to achieve this. Yes I want to achieve an average of the whole basket of orders.
Thanks
Carter
// Definition of code parameters
DEFPARAM CumulateOrders = true
// Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = high - ExponentialAverage[13](close)
indicator2 = high - ExponentialAverage[13](close)
c1 = (indicator1 >= indicator2[1])
indicator3 = high - ExponentialAverage[13](close)
c2 = (indicator3 < -20)
IF c1 AND c2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
exitprice = POSITIONPRICE + 15
sell at exitprice stop
// Stops and targets
//SET TARGET pPROFIT 10
I don’t know about the entry logic, but the exit one seems ok to me. You should adapt your exitprice variable to any instrument like this:
exitprice = POSITIONPRICE + 15*pipsize