Hi all,
I was wondering how to define my contract size to be 0.5 % of my account size, for example my stop loss I’d like to keep defined at 100 pips and then the contract size would be defined as a function of account size and pip value.
I found the “% max risk exposure” in the ProBacktest manual, but am not sure if this is along the right lines, could anyone please help?
Thanks!
This small snippet will calculate the lot size according to your account and risk in percentage.
//MM lot size
REM Money Management
Capital = 10000
Risk = 0.01 // = 1%
StopLoss = 100 // value of stoploss in pips/points
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
Many thanks Nicholas! I’ll give this a try.
I have also noticed that my live trade was closed on Friay night. This was not supposed to happen; it was nowhere near either the stop loss or take profit, could anyone please advise as to how I could stop this from happening?
I saw code with ‘lasttime’ and ‘opening time’ stipulated (https://www.prorealcode.com/topic/hold-over-the-weekend-or-not-test/); could these in some ways be used to let open trades carry on over the weekends?
Thanks again.
Trades will only close if you have instructions in your code to do so. Possibly your broker expanded the spread over the weekend that meant that one of your stop prices was met and the trade closed. If you believe that one of your trades was closed when it should not have been then you should contact your broker and ask them why it closed.
Thanks for the response Vonasi, it was a short trade and there was a gap down over the weekend, but this would still not have resulted in the TP being hit, I’ll ask the broker.
Thanks again,
Badar.