Indicates the current average position price of the whole opened orders.
If you open 3 positions, respectively at 5$, 10$ and 15$, POSITIONPRICE is : (5+10+15)/3 = 10€.
Syntax :
1 |
PositionPrice |
POSITIONPRICE can also be used to get the previous average position price in the last candle period with offset :
1 2 |
//average position price of the previous candle (n-1) PositionPrice[1] |
Example :
Floating profit of the whole opened orders
1 2 |
//floating profit floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains |
Averaging down simple trading strategy example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
myMACD = MACD[12,26,9](close) long = myMACD crosses over 0 //first order IF NOT LongOnMarket AND long THEN BUY 1 CONTRACTS AT MARKET ENDIF //averaging down IF TRADEINDEX(1)>5 AND TRADEPRICE(1)-Close>20 AND LongOnMarket THEN BUY 1 CONTRACTS AT MARKET ENDIF //closing all positions when current close is superior of the average positions price IF COUNTOFPOSITION >= 2 AND Close > POSITIONPRICE THEN SELL AT MARKET ENDIF SET TARGET PROFIT 20 |
With:
//floating profit
floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains
How would we close at a Profit of > 1% on LONG strategy?
You should use POSITIONPERF instead if you want to get the percentage profit, you’ll get it directly with this instruction.
Hey guys – I’ve been testing the floatingprofit example above and I’ve found a flaw. Seems that it calculates the total gain for the system rather than *only* the latent gain for open positions. Any ideas why?
I don’t think so. There’s no reason why it should take also closed positions into calculation.
how can I see the average “positionprice” of a scaled in position?
nevermind, it works now with graphonprice positionprice