Automated Real Trading - Get Started Quickly

CN
AICoin
Follow
1 year ago
```html

Overview

AICoin has launched the automated live trading feature, which allows users to define trading instructions through AICoin Script, start live trading, and place orders automatically! Click to join the community and discuss automated trading with more friends!

Usage Tutorial

Live Trading Example

// This indicator is created by AICOIN Research Institute. If you encounter any usage issues, you can join the indicator community for consultation
// @version=2

// Convert date to comparable time
t1 = parse_time("2023-11-01 22:42:00")
t2 = parse_time("2023-11-01 22:43:00")
t3 = parse_time("2023-11-01 22:44:00")
t4 = parse_time("2023-11-01 22:45:00")

// Define conditions
s1 = time == t1
s2 = time == t2
s3 = time == t3
s4 = time == t4

// Define trading instructions
// Open long position / spot buy
enterLong(s1, price='market', amount=1)
// Close long position / spot sell
exitLong(s2, price='market', amount=1)
// Open short position
enterShort(s3, price='market', amount=1)
// Close short position
exitShort(s4, price='market', amount=1)

// Plot closing price on chart
plot(close, title="Closing Price")

To learn more examples, please click the following hyperlinks to view:

    Automated Live Trading - Live Example of Signal Alert

    Automated Live Trading - Live Example of Indicator Win Rate

    Automated Live Trading - Live Example of Custom Indicator

1 Trading Function Explanation

1.1 Global Trading Configuration

// Declare strategy configuration, define relevant parameters. See the specific supported parameters in the strategy configuration field declaration below
tradeConfig(price="market", amount=1)

Parameter Explanation

``````html 2 现货合约交易配置

Open Long Position / Spot Buy

enterLong(condition, price="market", amount=1)

Close Long Position / Spot Sell

exitLong(condition, price="market", amount=1)

Open Short Position

enterShort(condition, price="market", amount=1)

Close Short Position

exitShort(condition, price="market", amount=1)

Parameter Explanation

Parameter

Explanation

price

last: limit order at the latest price; over: overpriced order, with the overpriced percentage following the PC system settings; queue: queued price; market: market order

Parameter

Explanation

condition

Boolean type, specifies the condition under which the trade is executed

Note: The parameters price/amount have the same meaning as in the global trading configuration. If these parameters are declared in the global configuration, they can be omitted, and the default will follow the global trading configuration

2 Function Usage Explanation

2.1 Specified Execution Order

Trading instructions will be executed in the order defined in the script. Please pay attention to the order of instructions. It is important to note that the execution order of instructions only guarantees the order placement. The order execution sequence is affected by the commission method and the exchange's matching engine behavior. If you encounter issues with order execution, you can contact customer service for assistance.

// The following format will first execute the close long position instruction, then execute the open long position instruction
exitLong(dead_cross)
enterLong(golden_cross)

// If written in this way, it will first execute the open long position instruction, then execute the close long position instruction
enterLong(golden_cross)
exitLong(dead_cross)

 

2.2 Instruction Quantity

You can only declare each type of instruction once. Repeated declaration of instructions will result in a compilation error

// The following format will result in a compilation error
enterLong(a)
enterLong(b)

 

2.3 Conditional Expression

The condition in the trading function is a boolean expression. When the condition is true, the specified trading action will be executed. For example:

enterLong(cross_up)
```3 Instruction Quantity Unit

As you can see, the quantity parameter `amount` of the instruction does not specify the unit. The actual unit of quantity when placing an order is determined by the unit selected on the live trading page. You can always confirm the setting of this unit in the live trading details.

Automated Live Trading - Quick Start_aicoin_Figure 1

 

2.4 Allowing Multiple Entries

Specifies whether the entry instruction is allowed to trigger multiple orders before the corresponding exit instruction appears. If unchecked, the entry instruction is not allowed to trigger consecutive orders, and consecutive entry instructions will not trigger orders. If checked, multiple entry instructions are allowed to trigger orders, and the number of times is determined by the configuration of multiple entry times.

For example:

Assuming the sequence of signals to be triggered is as follows

Not checked for multiple entries Checked for multiple entries, with a count of 2 Checked for multiple entries, with a count of 3

enterLong

Triggers order Triggers order Triggers order

enterLong

Does not trigger Triggers order Triggers order

enterLong

Does not trigger Does not trigger Triggers order

exitLong

Triggers order Triggers order Triggers order

enterLong

Triggers order Triggers order Triggers order

Additionally, only the corresponding exit instruction can reset the status of the corresponding entry instruction. The exit instruction for enterLong is exitLong, and the exit instruction for enterShort is exitShort. See another example below:

Assuming the sequence of signals to be triggered is as follows

Not checked for multiple entries Checked for multiple entries, with a count of 2 Checked for multiple entries, with a count of 3

enterLong

Does not trigger Does not trigger Triggers order

enterLong

Does not trigger Triggers order Triggers order

exitLong

Triggers order Triggers order Triggers order

Additionally, only the corresponding exit instruction can reset the status of the corresponding entry instruction. The exit instruction for enterLong is exitLong, and the exit instruction for enterShort is exitShort. See another example below:

enterLong

Does not trigger Triggers order Triggers order

 

2.5 Profit Calculation

Profit-related data is based on historical transaction information for statistical purposes. Funding fees and special cases of transaction fees (such as fee deduction) are temporarily not included in the statistics, so there may be some errors. It is for reference only. We recommend that you enable the asset statistics function to view the overall profit analysis of your account. Learn more about the asset statistics function.

Additionally, there are two points to note. First, you need to ensure that the PC end is running normally in order to correctly calculate the profit. Second, manual closing of positions may cause abnormal statistics of profit-related data.

 

Related Reading:

AICoin Automated Live Trading - Real-life Example of Signal Alerts

AICoin Automated Live Trading - Real-life Example of Indicator Win Rate

AICoin Automated Live Trading - Real-life Example of Custom Indicators

AICoin Automated Live Trading - Handling Common Issues

 

 

免责声明:本文章仅代表作者个人观点,不代表本平台的立场和观点。本文章仅供信息分享,不构成对任何人的任何投资建议。用户与作者之间的任何争议,与本平台无关。如网页中刊载的文章或图片涉及侵权,请提供相关的权利证明和身份证明发送邮件到support@aicoin.com,本平台相关工作人员将会进行核查。

Share To
APP

X

Telegram

Facebook

Reddit

CopyLink