# Spot Martingale KuCoin - The Quant Science

INTRODUCTION
Backtesting software of the Spot Martingale algorithm offered by the KuCoin exchange.

• This script replicates the logic used by the KuCoin bot and is useful for analyzing strategy on any cryptocurrency historical series.
• It's not intended as an automatic trading algorithm and does not offer the possibility of automatic order execution.
• The trader will use this software exclusively to research the best parameters with which to work on KuCoin.

LOGIC OF EXECUTION
The execution of orders is composed as follows:

1) Start Martingale: initial order
2) Martingale-Number: orders following Start Martingale

(A) The software is designed and developed to replicate trading without taking into account technical indicators or particular market conditions. The Initial Order (Start Martingale) will be executed immediately the close of the previous Martingale when the balance of market orders is zero. It will use the capital set in the Properties section for the initial order.

(B) After the first order, the software will open new orders as the price decreases. For orders following Start Martingale, the initial capital, multiplier, and number of orders in the exponential growth context are considered. The multiplier is the factor that determines the proportional increase in capital with each new order. The number of orders, indicates how many times the multiplier is applied to increase the investment.

Example
To find out the capital used in Martingale order number 5, with a Multiple For Position Increase equal to 2 and a starting capital of \$100, the formula will be as follows:

Martingale Order = (\$100 * (2 * 2 * 2 * 2 * 2)) = \$100 * 32 = \$3.200

(C) A multiplier is used for each new order that will increase the quantity purchased.

(D) All previously open orders are closed once the take profit is reached.

USER MANUAL
The user interface consists of two main sections:

1. Settings

Percentage Drop for Position Increase (0.1-15%): percentage distance between Martingale orders. For example, if you set 5% each new order will be opened after a 5% price decrease from the previous one.

Max Position Increases (1-15): number of Martingale orders to be executed after Start Martingale. For example, if you set 10, up to10 orders will be opened after Start Martingale.

Multiple For Position Increase (1-2x): capital multiplier. For example, if you set 2 each for each new order, the capital involved will be doubled, order by order.

Take Profit Percentage (0.5-1000%): percentage take profit, calculated on the average entry price.

2. Date Range Backtesting

The Date Range Backtesting section adjusts the analysis period. The user can easily adjust the UI parameters, and automatically the software will update the data.

LIMITATIONS OF THE MODEL
Although the Martingale model is widely used in position management, even this model has limitations and is subject to real risks during particular market conditions. Knowing these conditions will help you understand which asset is best to use the strategy on.

The main risks in adopting this automatic strategy are 2:

1) The price falls below our last order.
It happens during periods of strong bear-market in which the price collapses abruptly without experiencing any pullback. In this case the algorithm will enter a drawdown phase and the strategy will become a loser. The trader will then have to consider whether to wait for a price recovery or to incur a loss by manually closing the algorithm.

2) The price increases quickly.
It happens during periods of strong bull-market in which the price rises abruptly without experiencing any pullback. In this case the algorithm will not optimize order execution, working only with Start Martingale in the vast majority of trades. Given the exponential nature of the investment, the algorithm will in this case generate a profit that is always less than that of the reference market.

The best market conditions to use this strategy are characterized by high volatility such as correction phases during a bull run and/or markets that exhibit sideways price trends (such as areas of accumulation or congestion where price will generate many false signals).

FEATURES
This script was developed by including features to optimize the user experience.

• Includes a dashboard at launch that allows the user to intuitively enter backtesting parameters.
• Includes graphical indicator that helps the user analyze the behavior of the strategy.
• Includes a date period backtesting feature that allows the user to adjust and choose custom historical periods.

DISCLAIMER
This script was released using parameters researched solely for the BTC/USDT pair, 4H timeframe, traded on the KuCoin Exchange (2017-present). Do not consider this combination of parameters as universal and usable on all assets and timeframes.

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact thequantscience for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases you can find a good open-source alternative for free in our Community Scripts.

Disclaimer