TheTradingParrot

TTP Pair Cipher

TheTradingParrot تم تحديثه   
Pair Cipher can run your hedge pair trading strategy.

Pair cipher can use a spread chart (two assets ratio or difference) to manage a hedge position consisting of two assets: one long and one short position.

Event though the spread chart is used to determine the entries and exits each coin price action is used to calculate floating PNL.

It supports different bot platforms. It's backtestable and can run live.

Features:
- Internal and external entry signal
- In-chart realised PNL plot
- Hedge position floating PNL chart
- Individual floating PNL for each long and short ("show coins" toggle)
- Retracement exit strategy: determine at which retracement factor to exit your position while in profit
- PNL RSI exit strategy: determine at which RSI level crossunder you'd like to exit. RSI is applied to the floating PNL
- Static TP/SL levels
- ATR TP/SL levels with individual factors. When ATR is selected the TP or SL acts as a multiplier of ATR instead.
- On-chart debug labels for alerts
- Intra candle alert: signals can trigger intra candle in this mode, but this mode will cause repainting. Example: if the position goes below SL intra candle, the alert will be sent, but later if it goes in profit before closing the candle, the backtest will continue with the position open. The backtest does NOT have access to the intra candle data. Alert intra candle reduces the risk of not applying SL.


Example of setup:

1) Load an empty 1 hour timeframe chart with the spread BYBIT:REQUSDT.P / BYBIT:REEFUSDT.P
2) Select an investment amount
3) Select TP 1.2 and enable ATR
4) Select SL 1.1 and enable ATR
5) Select RSI profits of crossunder 70
6) Don't enable external signal (you can try with TTP PNR)
7) Select BYBIT:REQUSDT.P as symbol 1
8) Select BYBIT:REEFUSDT.P as symbol 2


ملاحظات الأخبار:
Fixed: coin labels were still showing with show coins disabled
ملاحظات الأخبار:
According to TradingView using spread charts can cause repainting. ( see spread
repainting
)

In order to prevent this you have to read candles settle one candle late and not just use this for tracking floating PNL but also for entry signals so they all occur consistently with the same timing.

Unfortunately this is not possible when using external signals that read the spread chart while we track floating PNL with one candle back in time since this causes to track profits from before the signal was triggered generating unrealistic inflated results.

I've decided to remove support for external signals and provide for now 2 deal start conditions that are applied to the non repainting settled spread: one candle back in time too.

RSI crossover and PNR crossover.

We could have decided to allow the strategy to repaint to use earlier data but that downside would have been that backtest will quickly get out of sync with the alerts. Using late data is not great but it guarantees that backtest does right what the live strategy does. The exchange can always update later their data on TV causing repainting but that is then impossible to avoid if they do so.
ملاحظات الأخبار:
Repaint toggle added. You decide!

Why using repainting? in repainting mode the strategy can take intra candle actions at the cost of backtests getting out of sync with real time.

If you don't allow repainting, backtest and real time should remain in sync (+99% probabilities). The trade-off is that the strategy will only use settle closed candles and it won't be able to take any intra candle decision. This includes all entry and exit events. This means that if you are trading on the 1 hour tf, for example, and the hedge position goes beyond TP or SL this won't activate until the candle closes. This could result in something good or bad depending on the final closing bar price action.
ملاحظات الأخبار:
Added max deal drawdown to the stats table. Useful to help with calculations of collateral needed. Different from the existing strategy DD which instead relates to the cumulative strategy PNL.
ملاحظات الأخبار:
Two spread modes are now supported:

1) Y/X
2) Y - Hedge *X + constant

Both modes are very popular among pair traders.

I recommend starting with 1) which doesn't use the Hedge and constant value.

Once feeling more confident you can later try using my recently released indicator TTP pair slope/hedge to assist calculating it the slope for a given period. Create an empty chart and plot the spread formula to confirm it helps to turn it into an stationary spread (staying flat as a horizontal line).

You can also use the new constant parameter if the resulting spread ever goes below 0. Just find the minimum value of spread and add a constant to push all values above 0.

Areas below 0 are not tradable since RSI and other indicators won't work properly.


You might notice there are OKX alert controls in this version. OKX alerts will remain disabled but stay tuned for OKX copy trading by end of October.
ملاحظات الأخبار:
Data window now also shows all the stats from the table.
ملاحظات الأخبار:
FIX: deal max drawdown was calculated wrongly in the stats table.
ملاحظات الأخبار:
Added Z-score filter: this will filter any entry signal if the Z-score value is not above the provided threshold parameter. Values of Z-score above 0 tend to revert.

I've seen good results when using values between -0.5 and 1.0 depending on the strategy used.

Join our membership to gain access to the private scripts.
www.thetradingparrot.com
نص برمجي محمي
تم نشر هذا النص البرمجي بمصدر غير مفتوح ويمكنك استخدامه بحرية. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني. لا يمكنك مشاهدة أو تعديل كود المصدر الخاص به.
إخلاء المسؤولية

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

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