Type/to search

Quantitative Trading Strategy Based on Random Numbers

Common strategy
Created: 2023-12-07 17:14:20
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

The core idea of this strategy is to simulate probability events such as coin flipping and dice rolling using random numbers to determine long or short positions, thus implementing random trading. This kind of trading strategy can be used for simulation testing and also as a basic framework for more complex strategy development.

Strategy Principle

  1. Use the flip variable to simulate random events and determine long or short based on the coinLabel random number size.

  2. Use risk and ratio to set stop loss and take profit lines.

  3. Trigger the next trading signal randomly according to the set maximum cycle number.

  4. Control whether to display the close position box through the plotBox variable.

  5. stoppedOut and takeProfit variables are used to detect stop loss or take profit.

  6. Provide backtesting capabilities to test strategy performance.

Advantage Analysis

  1. The code structure is clear and easy to understand and secondary develop.

  2. The UI interaction is friendly and various parameters can be adjusted through the graphical interface.

  3. The randomness is strong and not affected by market fluctuations, with high reliability.

  4. Better return on investment can be obtained through parameter optimization.

  5. Can be used as a demonstration or test for other strategies.

Risk Analysis

  1. Random trading cannot judge the market and there is a certain profit risk.

  2. Unable to determine the optimal parameter combination, repeated testing is required.

  3. There is a risk of super correlation that may result from overly dense random signals.

  4. It is recommended to use stop loss and take profit mechanisms to control risks.

  5. Risks can be reduced by appropriately extending the trading interval.

Optimization Directions

  1. Incorporate more complex factors to generate random signals.

  2. Increase trading varieties to expand test scope.

  3. Optimize UI interaction and increase strategy control capabilities.

  4. Provide more test tools and indicators for parameter optimization.

  5. Can be used as a trading signal or stop loss take profit component added to other strategies.

Summary

The overall framework of this strategy is complete, generating trading signals based on random events, with high reliability. At the same time, it provides parameter adjustment, backtesting, and charting capabilities. It can be used to test novice strategy development, and also as a basic module for other strategies. Through appropriate optimization, the strategy performance can be further improved.

Source
Pine
/*backtest
start: 2022-11-30 00:00:00
end: 2023-12-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © melodicfish

//@version=4
Strategy parameters
Strategy parameters
------- Trade Activity -------
Max Bars between Coin Filps
------- Position Settings -------
Risk in %
Risk to Reward Ratio x:1
------- Plot Options -------
Show Position Boxes
------- Back Testing -------
Run Strategy Back Test
Use Custom Date Range for back test
Test Start Year
Test Start Month
Test Start Day
Test Stop Year
Test Stop Month
Test Stop Day
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)