TradingView
facejungle
22 Eki 2023 01:18

2Mars - MA / BB / SuperTrend 

SOLUSDT Perpetual Swap ContractOKX

Açıklama


The 2Mars strategy is a trading approach that aims to improve trading efficiency by incorporating several simple order opening tactics. These tactics include moving average crossovers, Bollinger Bands, and SuperTrend.

Entering a Position with the 2Mars Strategy:
  • Moving Average Crossover: This method considers the crossing of moving averages as a signal to enter a position.
  • Price Crossing Bollinger Bands: If the price crosses either the upper or lower Bollinger Band, it is seen as a signal to enter a position.
  • Price Crossing Moving Average: If the price crosses the moving average, it is also considered a signal to enter a position.


SuperTrend and Bars confirm:

The SuperTrend indicator is used to provide additional confirmation for entering positions and setting stop loss levels. "Bars confirm" is used only for entry to positions.

Moving Average Crossover Strategy:

A moving average crossover refers to the point on a chart where there is a crossover of the signal or fast moving average, above or below the basis or slow moving average. This strategy also uses moving averages for additional orders #3.
  • Basis Moving Average Length: Ratio * Multiplier
  • Signal Moving Average Length: Multiplier


Bollinger Bands:

Bollinger Bands consist of three bands: an upper band, a lower band, and a basis moving average. However, the 2Mars strategy incorporates multiple upper and lower levels for position entry and take profit.
  • Basis +/- StdDev * 0.618
  • Basis +/- StdDev * 1.618
  • Basis +/- StdDev * 2.618


Additional Orders:
Additional Order #1 and #2: closing price crosses above or below the Bollinger Bands.
Additional Order #3: closing price crosses above or below the basis or signal moving average.

Take Profit:
The strategy includes three levels for taking profits, which are based on the Bollinger Bands. Additionally, a percentage of the position can be chosen to close long or short positions.

Limit Orders:
The strategy allows for entering a position using a limit order. The calculation for the limit order involves the Average True Range (ATR) for a specific period.
  • For long positions: Low price - ATR * Multiplier
  • For short positions: High price + ATR * Multiplier


Stop Loss:

To manage risk, the strategy recommends using stop loss options. The stop loss is updated with each entry order and take-profit level 3. When using the SuperTrend Confirmation, the stop loss requires confirmation of a trend change. It allows for flexible adjustment of the stop loss when the trend changes.
There are three options for setting the stop loss:
1. ATR (Average True Range):
  • For long positions: Low price - ATR * Long multiplier
  • For short positions: High price + ATR * Short multiplier

2. SuperTrend + ATR:
  • For long positions: SuperTrend - ATR * Long multiplier
  • For short positions: SuperTrend + ATR * Short multiplier

3. StdDev:
  • For long positions: StdDev - ATR * Long multiplier
  • For short positions: StdDev + ATR * Short multiplier


Flexible Stop Loss:
There is also a flexible stop loss option for the ATR and StdDev methods. It is triggered when the SuperTrend or moving average trend changes unfavorably.
  • For long positions: Stop-loss price + (ATR * Long multiplier) * Multiplier
  • For short positions: Stop-loss price - (ATR * Short multiplier) * Multiplier


How configure:
  • Disable SuperTrend, take profit, stop loss, additional orders and begin setting up a strategy.
  • Pick soucre data
  • Number of bars for confirm
  • Pick up the ratio of the base moving average and the signal moving average.
  • Set up a SuperTrend
  • Time for set up of the Bollinger Bands and the take profit
  • And finaly set up of stop loss and limit orders


All done!

For OKX exchange:
https://ru.tradingview.com/script/nzilXPNB-2Mars-strategy-OKX/

https://t.me/fj_2Mars

Sürüm Notları

Fixed minor errors

Sürüm Notları

Added:
  • Entry trigger
  • Stop-loss trigger
  • SuperTrend as entry signal
Yorumlar
ks1267
This looks very good. Have you tested if it's repainted?
facejungle
@ks1267, No repainting is required for this strategy ;)
Crossing moving averages, entering the market when the price crosses a certain level, take profit, stop loss - it is simple.
All that remains is to add automatic calculation of the most profitable settings, but it not about pinescript)
pinescript it is trouble
ks1267
@facejungle, Well done!!! You did a great job. Thank you so much.
ks1267
@facejungle, I have done forward tested and see that it is repaint. Tradingview sent alert at the wrong time and different time comparing with the backtest. Another problem is, when there is 1 buy/sell signal, tradingview sent multiple alerts at the same time (I receive about 15 alerts from tradingview per one signal). You can check it out and fix it.
facejungle
@ks1267, I wonder where you found the repaint)
When a position is reversed, two signals are sent: one to close and one to enter.
I've been using the OKX version for over two months now.

And I just took another test.
All OK.
Check your settings
facejungle
@ks1267, The signal delay can reach more than 50 minutes :D
For the OKX exchange the maximum delay parameter can be configured, for others - as far as I know, not.
For example, when I traded on Bybit, more than half of the signals were expired.
ks1267
@facejungle, The signal delay can read more than 50 minutes. That's not very good, isn't it? In an hour the price can be drastically different.

Not sure if I set anything wrong but I used the default setting. The problem at my end is not the exchange. It's the problem from tradingview alert as I mentioned earlier. When the strategy having a buy/sell signal, tradingview will then send around 15 alerts repeatedly of the same alert which confuses the exchange. Also the repaint, when you forward run the strategy, you would get a set of positions. But when you open tradingview and check the positions in the back test, they are different set (different time) as when you do forward test. I will try to change the setting and see how it goes. Thanks for your advice.
facejungle
@ks1267, Yes, this is bad, like many things in signal trading TradingView.
A large number of notifications may be due to calculations on each tick.
The most interesting thing is that if you check that the bar has closed, the strategy will be redrawn, which will not comply with the TradingView rules.
barstate.isconfirmed - Please note that using this variable/function can cause indicator repainting.
Therefore, I am writing a normal service not on TradingView.
facejungle
@ks1267, I found one crutch, I'll try it and maybe there will be an update
ks1267
@facejungle, Thank you so much.
Daha Fazla