This code helps you to trail a discretionary short position in USDJPY or any other USDXXX pairs. You enter the level where you want to go short with a stop entry order and you enter the level where you want your stoploss. Additionally you enter the spread and your accountsize and the EURUSD conversion (for euro accounts). Your positionsize is calculated based on 0.5% risk of your accountsize. If you use a 1 minute timeframe, the stop entry order will be placed within a minute after running the strategy. You will be filled once the price hits your stop entry order. The stoploss order will now be placed with a 0.5% risk of your accountsize. Once the position comes into profit, half of your position will be exited when the close of the 1h chart crosses above the moving average 10. The remaining position will be closed once the close of the 1h chart crosses above the moving average 20. In case the 1h closes above the moving average 20 without closing above the moving average 10 first, your full position will be closed at once.
This code is quite specific, but hopefully it can be useful for those who want do do something similar.
(This is not a fully automated strategy)
manual entry with automated trailing MA 10 and 20 pn 1h
// manualy enter these variables
// calculate the desired loss and adjust the entrylevels for spread
Trading on leveraged financial instruments may expose you to risk of loss greater than your deposits and is only suitable for experienced clients with the financial means to bear such risk. Trading on foreign exchange instruments (Forex) and contracts for difference (CFDs) is highly speculative and particularly complex and comes with a high level of risk due to leverage. You must ensure that you understand how these instruments work and that you can afford to take the high risk of losing your money. No information on this site is investment advice or a solicitation to buy or sell any financial instruments.