J.Participant
Average
Hello, can strategyprofit be negative?
I’m trying to make my position sizing dynamic based on how much capital I have.
STARTINGCAPITAL = x //eg 5000 EUR
SIZE = 2 / STARTINGCAPITAL //size starts with 2
CAPITAL = STARTINGCAPITAL + STRATEGYPROFIT //current capital
AMOUNT = CAPITAL * SIZE //calculate position size
I noticed in backtesting that my position sizing won’t go down after having a negative start.
Is there a better way to do this?
Thanks
J.Participant
Average
Quick side note: I’m using this to open and close positions, could it be that I first have to give a Sell and Exitshort command for my dynamic sizing to work?
IF c1 THEN
BUY AMOUNT CONTRACT AT MARKET
ENDIF
IF c2 THEN
SELLSHORT AMOUNT CONTRACT AT MARKET
ENDIF
Edit: tested it and it didn’t work either.
Strategyprofit is updated with positions closed. So you have to close positions in order to use strategyprofit to calculate your new position size.
However you can also use this snippet to compute in real time the floating profit of the open orders at market:
//floating profit
floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains