Automatic Amount Calculation
While in Italy, I experienced a series of loss trades that, overall, were larger than expected. As the stop amount moves around for every trade, sometimes it can be large and sometimes smaller. This means using a fixed amount exposed me to greater risk occasionally, and unfortunately I lost.
I have now implemented the logic to calculate the amount based off a percentage input of the account balance, and the stop value. This is much safer and allows me to always ensure my bets are 1-2% of my account balance. However, a traditional amount input is still required if a stop is not used of course. While I suspect this will be legacy, I have implemented it anyway.
It is worth highlighting that this kind of account/PnL logic depends heavily on the PipCost. I thought I could calculate the PipCost on the initialization of the strategy but of course as the markets move so does the PipCost, therefore, it must be recalculated before every trade. I have come up with the following formula that we can calculate the notional amount knowing the other factors.
Notional = (Risk * PipSize * BaseSize) / (StopValue * PipCost)
Risk is the acceptable amount of money we can lose in Account Currency
StopValue is the price differential from the current price to the Stop price. i.e. a stop of 100 pips for AUDJPY would be represented by a change in price (stopValue) by 1.0
* Note that the Notional must be divisible by the BaseSize for it to be valid.
While in Italy and experiencing the failures mentioned in an earlier entry, I would receive email notification from the strategy of a trade opportunity but the trade did not execute. After this, I would want to execute the trade manually if it was still opportune to do so, however, the email didn’t provide me with all the necessary information to do so.
Thus, I have improved the email notification for the strategies such that it includes all information necessary to manually execute the trade. I.e., The quantity, the actual price to use taking into account the side, detailing both sides of the price, and the stop and limit values if applicable.
Today I made a quick enhancement to Update Stops such that it takes in a % input to determine when the stops should be moved to the break-even point. The idea here is that 50% may be premature sometimes… if it gets say 80% of the way there then we have a pretty good chance it will go all the way, so move the stops to protect us.