tradingw999

Strategy Container_Variable Pyramiding & Leverage [Tradingwhale]

This is a strategy container. It doesn’t provide a trading strategy. What it does is provide functionality that is not readily available with standard strategy ’shells.’

More specifically, this Strategy Container enables Tradingview users to create trading strategies without knowing any Pine Script code.

Furthermore, you can use most indicators on tradingview to build a strategy without any coding at all, whether or not you have access to the code.

To illustrate a possible output in the image (buy and sell orders) of this strategy container, we are using here an indicator that provides buy and sell signals, only for illustration purposes. Again, this is a strategy container, not a strategy. So we need to include an indicator with this published strategy to be able to show the strategy execution.

What can you do with this strategy container? Please read below.

Trade Direction
You can select to trade Long trades only, Short trades only, or both, assuming that whatever strategy you create with this container will produce buy and sell signals.

Exit on Opposite
You can select if Long signals cause the exit of Short positions and vice versa. If you turn this on, then a sell/short signal will cause the closing of your entire long position, and a buy/long signal will cause the closing of your entire short position.


Use external data sources (indicators) to (a) import signals, or (b) create trading signals using almost any of the indicators available on Tradingview.

Option 1:
When you check the box ‘Use external indicator Buy & Sell signals?’ and continue to select an external indicator that plots LONG/BUY signals as value '1' and SHORT/SELL signals as value '-1, then this strategy container will use those signals for the strategy, in combination with all other available settings.

Here an example of code in an indicator that you could use to import signals with this strategy container:
buy = long_cond and barstate.isconfirmed
sell = short_cond and barstate.isconfirmed
//—------- Signal for Strategy
signal = buy ? 1 : sell ? -1 : 0
plot(plot_connector? signal : na, title="OMEGA Signals", display = display.none)

Option 2:
You can create buy/long and sell/short signals from within this strategy container under the sections called “Define 'LONG' Signal” and “Define 'SHORT' Signal.”

You can do this with a single external indicator, by comparing two external indicators, or by comparing one external indicator with a fixed value. The indicator/s you use need to be on the same chart as this strategy container. You can add up to two (2) external indicators that can be compared to each other at a time. A checkbox allows you to select whether the logical operation is executed between Source #1 and #2, between Source # 1 and an absolute value, or just by analyzing the behavior of Source #1.
Without an image of the strategy container settings it’s a bit hard to explain. However, below you see a list of all possible operations.

Operations available, whenever possible based on source data, include:
- "crossing"
- "crossing up"
- "crossing down"
- "rejected from resistance (Source #1) in the last bar", which means ‘High’ was above Source #1 (resistance level) in the last completed bar and 'Close' (current price of the symbol) is now below Source #1" (resistance level).
- "rejected from resistance (Source #1) in the last 2 bars", which means ‘High’ was above Source #1 (resistance level) in one of the last two (2) completed bars and 'Close' (current price of the symbol) is now below Source #1" (resistance level).
- "rejected from support (Source #1) in the last bar" --- similar to above except with Lows and rejection from support level
- "rejected from support (Source #1) in the last 2 bars" --- similar to above except with Lows and rejection from support level
- "greater than"
- "less than"
- "is up"
- "is down"
- "is up %"
- "is down %"

Variable Pyramiding, Leverage, and Pyramiding Direction

Variable Pyramiding
With this strategy container, you can define how much capital you want to invest for three consecutive trades in the same direction (pyramiding). You can define what percentage of your equity you want to invest for each pyramid-trade separately, which means they don’t have to be identical.
As an example: You can invest 5% in the first trade let’s call this pyramid trade #0), 10% in the second trade (pyramid trade #1), and 7% in the third trade (pyramid trade #2), or any other combination. If your trading strategy doesn’t produce pyramid trading opportunities (consecutive trades in the same direction), then the pyramid trade settings won’t come to bear for the second and third trades, because only the first trade will be executed with each signal.

Leverage
You can enter numbers for the three pyramid trades that are combined greater than 100%. Once that is the case, you are using leverage in your trades and have to manage the risk that is associated with that.

Pyramiding Direction
You can decide to scale only into Winners, Losers, or Both. Pyramid into a:
- Losers: A losing streak occurs when the price of the underlying security at the current signal is lower than the average cost of the position.
- Winners: A winning streak occurs when the price of the underlying security at the current signal is higher than the average cost of the position.
- Both means that you are selecting to scale/pyramid into both Winning and Losing streaks.

Other Inputs that influence signal execution:
You can choose to turn these on or off.

1. Limit Long exits with a WMA to stay longer in Long positions: If you check this box and enter a Length number (integer) for the WMA (Weighted Moving Average), then Long positions can only be exited with short signals when the current WMA is lower than on the previous bar/candle. Short signals sometimes increase with uptrends. We’re using this WMA here to limit short signals by adding another condition (WMA going down) for the short signal to be valid.

2. Maximum length of trades in the number of candles. Positions that have been in place for the specified number of trades are excited automatically.

3. Set the backtest period (from-to). Only trades within this range will be executed.

4. Market Volatility Adjustment Settings
- Use ATR to limit when Long trades can be entered (enter ATR length and Offset). We’re using the 3-day ATR here, with your entries for ATR length and offset. When the 3-day ATR is below its signal line, then Long trades are enabled; otherwise, they are not.
- Use VIX to limit when Short trades can be entered (enter VIX). If you select this checkbox, then Short trades will only be executed if the daily VIX is above your set value.
- Use Momentum Algo functions to limit Short trades. This uses the average distance of Momentum Highs and Lows over the lookback period to gauge whether markets are calm or swinging more profoundly. Based on that you can limit short entries to more volatile market regimes.
Set:
- Fast EMA and Slow EMA period lengths
- Number of left and right candles for High and Low pivots
- Lookback period to calculate the High/Low average and then the distance between the two.

The assumption here is that greater distances between momentum highs and lows correlate positively with greater volatility and greater swings in the underlying security.

Stop-Loss
Set separate stop-losses based on % for Long and Short positions. If the position loses X% since entry, then the position will be closed.

Take-Profit
Set separate take-profit levels based on % for Long and Short positions. If the position wins X% since entry, then the position will be closed.

TradingWhale 'invite-only' indicator, signal and strategy scripts are available on www.tradingwhale.io. We offer a 7-day free trial on all subscriptions.
보호된 스크립트입니다
이 스크립트는 클로즈 소스로 게시되며 자유롭게 사용할 수 있습니다. 당신은 스크립트를 차트에 사용하기 위해 그것을 즐겨찾기 할 수 있습니다. 소스 코드는 보거나 수정할 수 없습니다.
면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?