Giter Club home page Giter Club logo

algo_trading_weighted_strategy's Introduction

Weighted strategy

tradingview last modified license referral


Note

This project is on hold until further news. The idea is to take it up again when I defend my PhD in June 2023.

Best,

Alberto


I have been developing a fully customizable Algorithmic Trading Weighted Strategy in Pine Script for the last year in my spare time. The algorithm is based on a set of well-documented strategies, each with its own weight (weighted strategy). Currently a set of 5 strategies have been implemented:

  • MACD
  • Stochastic RSI
  • RSI
  • Supertrend
  • MA crossover

Moreover, the algo includes stop losses criteria and a taking profit strategy. The algo must be optimized for the desired asset to achieves its full potential. The 4H dataframe gives good results. The algo has been tested for several asset (same dataframe, different optimization values).

To set an order, first, the algorithm calculates the weight_strategy, which represents a value from 0 to 5 of the number of strategies that are satisfied (in case the weight of each strategy is the same, i.e., same relevance over the rest). To open a position, the value of weight_strategy must be greater than the value of weight_signal, by default 2. Modify the indicator parameters for the desired asset and data frame. Set stop-loss and take profit criteria.

Pro and Premium version (in Development)

There are two additional new versions of the algorithm under development:

  • Pro:
    • complete alert system โœ… ๐Ÿ›
    • access to a telegram channel with instant signals of BTC/USDT โœ… ๐Ÿ›
    • new entry strategy based on limit orders instead of market orders as in the basic plan ๐Ÿ‘จโ€๐Ÿญ
    • more control of the stop-loss and take profits orders ๐Ÿ‘จโ€๐Ÿญ
  • Premium:
    • all of pro version
    • kernel based on more sophisticated indicators ๐Ÿ‘จโ€๐Ÿญ
    • compatible with 3Commas
    • access to the premium telegram channel with instant signals of BTC/USDT and few altcoins โœ… ๐Ÿ›
    • the premium telegram channel allows auto-trading with the use of a secure third-platform API โœ… ๐Ÿ›
    • access to more reliable signals based on an in-house optimization algorithm ๐Ÿ‘จโ€๐Ÿญ

Features:

  • The algorithm allows to trade with long, short or both positions.
  • Backtest the algorithm over a defined interval (data stamp), e.g., from 01/01/2021 to 01/01/2022.
  • Set stoploss (SL) orders based on a percentage of the previous candle source, e.g., close or hl2 (high + low)/2. The position will only be closed if after the candle closes, it still meets the stop condition.
  • Set SL to previous TP targets.
  • Set SL to the average position (after TP).
  • Stop position in case the algo detects a potential Top/Bottom.
    • It can close a specific percentage of the remaining open long position.
    • It can close a specific percentage of the remaining open short position.
  • It can moves the stoploss every time the algo takes profit (TP)
  • Take profit based on a percentage of the open position. It is possible to define different values for short positions. Define the percentage of TP to close from the open position.
  • Choose the maximum number of Take Profits (TP)
  • Define delays to evaluate the strategies of more previous candles:
    • Candle Delay is for MACD strategy
    • Candle Delay Stoch RSI is for the Stochastic RSI strategy.
    • Candle Delay RSI is for the RSI strategy.
    • Candle Delay Exit is the number of candles the algorithm waits to open a new position.
  • Choose if you want to use the weighted strategy or just some of them.
  • Choose the weight (relevance) of each strategy.
  • Customize the well-documented MACD strategy.
  • Customize the well-documented Stochastic RSI strategy.
  • Customize the well-documented RSI strategy.
  • Customize the well-documented Supertrend strategy.
  • Customize the well documented MA cross strategy.
  • Buy/sell labels for possible reentries.
  • Monthly table performance.
  • Configurable alarm system.

โš ๏ธ NOTE

  • Backtest the algorithm with different data stamps to avoid overfitting results.
  • The given default setup correspond with a successful example to use with H4 $BTC/$USDT on @binance with +1700% in one year with a max drawdown of 8% approx. With the monthly performance, we can see that the algo has performed very well over the past two years, capturing the trend very accurately. However, from 2017 to 2019, the algorithm can't even make a profit! This is a disclaimer, use at your own risk.

Plots

  • The color-trend represents when at least one of the strategies is satisfied, long in teal and short in gray and there is not a draw, same number of strategies satisfies for long and short.
  • The + represent the next Take Profit (TP) target in teal and the Stop-Loss (SL) in gray.
  • Plot labels for every time each strategy satisfies to open a long/short position
  • Spot potential local Tops (T) and Bottoms (B) based on a combination of RSI, Stoch RSI, MACD, volume, and the weighted-strategy.

Examples

  • H4 BTC/USDT Binance (default) - 01/01/2021 - 19/02/2022

How to use it

Search for Acrypto - Weighted strategy in the indicator tab using TradingView and add it to your layout. Modify the indicator parameters for the desired asset and data frame.

If you consider paying for a subscription on TradingView (which is not required for this script), I would be very grateful if you could use my referral link :)

Referral link: https://www.tradingview.com/gopro/?share_your_love=accry

Original post: https://www.tradingview.com/script/OF3TzrNS-Acrypto-Weighted-Strategy/

Acknowledgements

The monthly table performance was developed by @QuantNomad. I have only changed some colors and also adapted the calculations to the last previous candle. The purpose of this change is to make this script compatible with this weighted strategy. Thanks again to @QuantNomad for this amazing script!

Questions?

For discussions, questions, or just to share some settings, please leave a comment here in the discussion channel.

Developer

Support this project by giving me an extra dose of caffeine โ˜•

Buy Me A Coffee

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

algo_trading_weighted_strategy's People

Contributors

albertocuadra avatar thouravi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

algo_trading_weighted_strategy's Issues

Different Signals on Different Version

Hey,

So on the v1.4.2 I just got a short signal on BTCUSDT 4H.
image

On v1.4.3. it's still showing long signal.
image

And the only difference in both these version is this:
image

What should I rely on? This is really confusing.

Presets Feature

Is there a way to integrate Presets for switch between own settings?

Two Minor Changes Increased Net Profit %

Hey,

I tested your strategy and on changing two values, it increased

  • Net Profit from 1819% to 2206%
  • Profit Factor from 4.482 to 8.152
    on 4H BTC/USDT Binance.

Change 1: Line 73

Before - 27
short_RSI = input.float(27, 'Exit SRSI Short (%)', minval=0.0, step=1, group='Strategy 2: Stoch RSI')

My Change - 21
short_RSI = input.float(21, 'Exit SRSI Short (%)', minval=0.0, step=1, group='Strategy 2: Stoch RSI')

Change 2: Line 92

Before - 88
MA2_period_5 = input.int(88, 'MA 2', minval=1, maxval=9999, step=1, group='Strategy 5: MA CROSS')

My Change - 85
MA2_period_5 = input.int(85, 'MA 2', minval=1, maxval=9999, step=1, group='Strategy 5: MA CROSS')

Change 3 - Line 42

Before
MAX_TP = input.int(6, 'Max number of TP', minval=1, maxval=6, group='Take Profits')

My Change
MAX_TP = input.int(3, 'Max number of TP', minval=1, maxval=6, group='Take Profits')

Change 4 - Line 36

Before
stoploss_perc= input.float(6.0, 'Stop Loss %', minval=0, maxval=100, group='Stop loss') * 0.01

My Change
stoploss_perc= input.float(8, 'Stop Loss %', minval=0, maxval=100, group='Stop loss') * 0.01

Let me know what do you think, my username on TradingView is ImThour.
Let's have a chat, cheers.

Error: incompatibility with pyramiding

i had this strategy running well for a few days with pyramiding settings at 2 orders ,take profit orders at 4
seems like the second buy and 4 take profit orders executed instantly
any idea what can cause this issue?

image

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.