Hello everyone, I'd like to ask for some help here. This simple strategy I made of 2 EMA crossovers has 60% winrate and parameter set RRR of 1.5, so expectancy should be 50%. My problem is that I noticed different currency pairs have death-periods where no matter how I try to alter my parameters they always blow up an account in that period, making it impossible for the strategy to capitalise on long term expectancy.
For EURUSD this period is always May 24th - Jun 4th when using 15, 5 or 30min TF. I found this death period through multiple different parameters testing. Anyone know what countermeasures I can implement to prevent these death pitfalls. I can think of a maximum weekly 10% account loss (with 2% SL impact that would be 5 trades lost in a row), after which strategy freezes for 7 days to give market time to start trending again. I'm just unsure how can I check if strategy won or lost a trade.
Thank you for your time, Vedran
Shile Wen
Hi Vedran,
As EMA Crossover is momentum based, I'd suggest gauging the strength of the trend using the Hurst Exponent. In addition, try different asset classes to see if this type of algorithm performs better.
Best,
Shile Wen
Vedran Mrkonjic Durokovic
Hi Shile,
First of thanks for the reply, big fan of your YouTube content. I've been meaning to implement Hurst exponent or maybe Williams Aligator indicator or 200EMA to check for trend direction,
But I meant to ask how can I get the result from last strategy trade in a way such as this:
if TradeLost == True: doThis
Is there a method that allows me to grab previous trade result data, such as whether stopOrder or limitOrder was hit?
OkiTrader
Hi Vedran,
I had a similar problem. I fixed it in my backtest by applying account % risk drops instead of a stop-limit order. The answer lies somewhere in your lot rounding and margin calculations. For example, there are about 50 pages of the following:
2020-05-28 09:30:00 :Warning: To meet brokerage precision requirements, order LimitPrice was rounded to 1.11380 from 1.11380000000000012020-05-29 06:06:00 :Order Error: id: 587, Insufficient buying power to complete order (Value:-5561.325), Reason: Id: 587, Initial Margin: -111.4265, Free Margin: 77.6329.You can also send yourself email notifications of your trading activity. I definitely would not go live without it.
https://www.quantconnect.com/docs/live-trading/notifications#Notifications-Email-NotificationsOther note
Vedran Mrkonjic Durokovic
Hi OkiTrader ,
Thank you for your response, but could you please clarify what you meant by "% risk drop"? Do you mean as making a max drawdown risk management? I'm calculating position size that at stoploss account loses a fix % (usually 1% or 2% account value), generates that * RRR (usually 3% account value for 1.5RRR).
Thank you for your time, Vedran
OkiTrader
I used a version of Alex Catarino's
class TrailingStopRiskManagementModel(RiskManagementModel): '''Provides an implementation of IRiskManagementModel that limits the maximum possible loss measured from the highest unrealized profit''' def __init__(self, maximumDrawdownPercent = 0.05): '''Initializes a new instance of the TrailingStopRiskManagementModel class Args: maximumDrawdownPercent: The maximum percentage drawdown allowed for algorithm portfolio compared with the highest unrealized profit, defaults to 5% drawdown''' self.maximumDrawdownPercent = -abs(maximumDrawdownPercent) self.trailingHighs = dict()
https://github.com/QuantConnect/Lean/blob/master/Algorithm.Framework/Risk/TrailingStopRiskManagementModel.pyShile Wen
Hi Vedran,
We can use self.Portfolio[symbol].LastTradeProfit to get the last trade profit for a given symbol, and we can tell if it is a loss if it's negative. Alternatively, we can track this information in OnOrderEvent, though we should keep track of the OrderTickets (which are returned by an order method, such as MarketOrder) in a dict indexed by its OrderId.
Best,
Shile Wen
Vedran Mrkonjic Durokovic
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!