DojiEmoji

Mean Reversion Strategy v2 [KL]

DojiEmoji تم تحديثه   
Description:
This strategy will enter a position when the following conditions are met:
a) Main signal: When source data (ATR) diverts from its moving average value, and
b) Confirmation: If predicted direction of trend is favorable.

Assumptions:
During periods of high price volatility, ATR diverts from its moving average value. Eventually, ATR should revert. But since just knowing the magnitude of increase/decrease of ATR does not indicate a trend signal, we need to introduce a model to predict the current trend.

In short:
Trend Prediction: This strategy calculates the expected logarithmic return of the security (the "Drift") and considers prices to be moving in uptrend if the drift curve is upward sloping.
Assessment of ATR diversion: To determine "yes/no" regarding whether ATR at a given point in time has diverted, this script conducts a two-tailed hypothesis test at each candlestick period. The null hypothesis (H0) is that the fast moving average value should equal the slow moving average value (say, denoted as H0: atr14 == atr28; it is assumed that atr28 is more meaningful for the purpose of describing the current trend because it has a larger sample size). Investopedia has an article summarizing this topic <link>.

Exit Condition:
When trailing stop loss hits.

Previous version:
This strategy is based on Version 1 published back in September <link>. This older version considers +/- one standard deviation to be the critical values relative to average ATR when testing whether ATR has diverted from the mean. This does not take Standard Error ("SE") into account. As a result, the threshold is often too wide and it generates too many entry signals.
ملاحظات الأخبار:
• added annotations to the chart
ملاحظات الأخبار:
Added explanations (// in-line comments in codes) in the block labeled "ATR diversion test".
ملاحظات الأخبار:
Added profit taking levels. Also amended risk management strategy.

Changes:
- Order size is based on user-defined percentage of committed capital
- Profit taking over 3 levels based on risk to reward ratio (i.e. 1R, 2R, 3R). When a target is met at each tier, strategy will close out one third of current position size. As for remainders of unrealized profits (i.e. already taken once at 1R, but not yet reach 2R or 3R), unreached targets will eventually be closed at the trailing stoploss price
ملاحظات الأخبار:
Fixed a bug relating to profit taking over 3 levels (described in the previous update).
ملاحظات الأخبار:
Added dropdown menu to select confidence interval (previously had to manually key in critical value)
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟