• Language & Exchange Rate Switch
  • Preference Settings
    Rise/fall colour
    Start-End Time of the Change
Announcements
Activities
Bi-Weekly Report
Institutional & VIP
Gate Learn
Delisting
Gate Wealth
New Cryptocurrency Listings
Gate Charity
Finance
Trading Competitions
Deposit & Withdrawal
ETF
Live
Gate Card
Token Rename
Announcements Custom Strategy of Trading Bot
Custom Strategy of Trading Bot
2022-01-07 04:06:07 UTC 31882 Read

1. What is Custom Strategy?


A custom strategy is a strategy that allows users to formulate trading rules, which is applicable to all users. For new users of Trading Bot, custom strategies can combine simple trading rules, such as "when the spot price of GT is higher than 10 USDT, sell the GT held at the price of 10 USDT".

For professional users, custom strategies can also satisfy their need for complex trading logic, such as "when the spot price of BTC is higher than 50,000 USDT and the ratio of BTC Futures price to the index price is higher than 1, 4 pieces of BTC will be sold and 0.01 BTC will be bought at the price of 51,000 USDT at the same time."



2. Instructions of Custom Strategy


Navigation bar - "Trading Bots" - "Create New Strategy" - select "Custom Strategy" - "Strategy Library" - click "Add Rule/Variables" - click "Save and Run", as shown in the figure below:





2.1 Add rules

Click "Add Rule" to add previously created rules or create new rules.
+New Rules

Rules are mainly composed of conditions and execution logic.



1.Conditions

Conditions are preset specific ones for triggering execution logic. Users can use the existing market data of Gate.io, strategy's capital data, and mathematical functions provided by the platform to combine conditions that you need.

Click on the icon to choose all the data that is available



Click "Applicable Function Description" to view the specific usage methods of all data

Example: This rule is triggered when the BTC spot price exceeds 50,000 USDT,

Condition: price(“BTC_USDT”, 0, “spot”)>50000 can satisfy more complex strategies,

For example, multiple conditions are required:

1. When the Futures price of BTC_USDT is lower than 50,000 USDT

2. The premium of the Futures price of BTC_USDT to the index price is greater than 1

3. BTC_USDT position is 0

Condition: price(“BTC_USDT”, 0, "usdt") < 50000 and premium(“BTC_USDT”, 0, "usdt") > 1 and (position_net(“BTC_USDT”, "usdt") == 0)

2.Execution Logic

Execution logic is used to preset what order to execute when the condition is triggered. Users can execute Spot and Futures orders and create their own functions (variables) through the execution logic provided by Gate.io. Type is used to select the trading type, including Spot trading or Futures trading; the market is used to select the market for strategy transactions. One rule enables multiple execution logics to select different markets, up to 20 markets; Order Type provides multiple orders, Limit price, market price, take-profit, stop-loss.Example: To sell BTC after the price of BTC Spot exceeds 50,000 USDT, the execution logic is:


When the price of BTC Future is lower than 5000 USDT, open a long position of 5 times, the execution logic is:


A rule allows multiple execution logics to execute together, and supports up to 20 execution logics to execute together.

2.2 Add Variables

Click "Add Variables" to add previously created variables or create new variables.


New Variables

Variables are mainly composed of conditions and variable values. Users can save any variable, and only need to get the value of "variable_name" through "get_value("variable_name")" when using it.

1.Conditions

Conditions are preset specific conditions used to trigger the calculation of variable values. Users can use Gate.io's existing market data, strategy fund data, and mathematical functions provided by the platform to combine conditions to meet your needs.


Click on the icon to select all data provided

Click "Applicable Function Description" to view the specific usage methods of all data

Example: Just like the method used in the conditions in the rules.

2.Variable Value

It is used to preset what variable value will be stored when the condition is triggered, and you can create a variable value from the data provided by Gate.io.

Example: get the EMA10-minute indicator of spot BTC all the time, and the variable value is:


The variable value increases by 10 after each trigger, and the variable value is:
--
When adding a variable or rule, if the variable value or condition and execution logic refer to other variables, you need to add the other variable at the same time, otherwise you can't get correct variable value or condition or execution logic.

2.3 Order of Execution


The custom strategy loops every 10 seconds and executes all the rules and variables in the strategy from low to high in the order of execution. If there is a reference relationship between variables or rules, you need to add the referenced variable first, otherwise you will not be able to get the desired effects as you expect.

For example: as shown in the above strategy, ema-BTC is used as a condition in "buy BTC, sell BTC". When the conditions are met, the strategy needs to buy BTC first and then sell BTC. The order of adding this strategy should be "ema-BTC, buy BTC, sell BTC".

2.4 Save and Run

3. You can select "Save" to save the newly created strategy to the strategy library and run it later. When running a strategy, you only need to click on the strategy library to run it, and the strategy saved in the strategy library can be run multiple times.

3.You can also choose "Save and Run" to save the newly created strategy to the strategy library and invest funds to run it.


2.5 Enabling and Disabling

After creating a strategy, the rules and variables in the strategy are enabled by default. When editing the strategy, you can disable or enable the rules and variables. After clicking "Save", the operation will take effect immediately and directly affect the ongoing strategy.


1.When disabling rules and variables, "Disable" means disabling this rule or variable in this strategy, and "Disable all" means disabling all the rules or variables in this strategy.


Gate.io reserves the final right to interpret the product.

Share Posts
Related Articles
[Lead Trader] FAQ [Lead Trader] How to Apply for Gate.io Lead Trader? Guide to Following Strategies(on APP) Backtest Strategy Instruction How to View Active & Historical Strategies Gate.io One-click Intelligent Copy Trading Strategy : (Initial Creators Enjoy 5%~30% Profit Sharing...
Language and Region
Exchange Rate
Go to Gate.TR?
Gate.TR is online now.
You can click and go to Gate.TR or stay at Gate.io.