Download
Download by
Scanning QR Code
  • Download app

    Download app

  • Online Inquiry

    Log in to access Online Inquiry
+
Congratulations
You've successfully got advanced quotes worth 5000 HKD
Download APP >>

Common scenarios & methods

Create a strategy to open/close a position only once

If a signal continuously meets the condition, the strategy may repeatedly execute the 「Place Order」.

How to ensure the strategy buys or sells only once when the signal meets the condition? Here are the two simplest methods.

Method 1: Determine positions

If the strategy places a type of order that can be filled quickly (e.g., a market order), then you can indirectly determine whether a position has been opened or closed successfully through the underlying stocks you are holding.

● If the number of underlying stocks you are holding is > 0, then the position has been opened successfully, and the path to close positions will run;

● If the number of underlying stocks you are holding is 0, then the position has been closed successfully or has not been opened, and the path to open positions will run;

Note: This method requires that the order must be filled quickly; otherwise repeated orders may still be placed.

Method 2: Use a counter

If the strategy places a type of order that may not be filled quickly (e.g., a limit order), you can create a value global variable as a counter to indicate whether an order has been placed.

Step 1: Go to Start > Properties > Global Variables, and create a counter named "a" to indicate whether a buy/sell order has been placed.

● If a buy order has been placed, it will be represented by 1;

● If no order has been placed, it will be represented by 0;

● If a sell order has been placed, it will be represented by -1.

According to the above rules, the value of the global variable "a" is 0 by default (indicating that no order has been placed).

Step 2: Determine the global variable "a" and the number of holdings first when the strategy starts to run:

● If "a" = 0, and the number of holdings = 0, it means that no order has been placed and no position is held, and the path to open positions will run;

● If "a" = 1, and the number of holdings > 0, it means that a buy order has been placed and there are positions held (the buy order has been filled), and the path to close positions will run;

● If "a" = -1, and the number of holdings = 0, it means that a sell order has been placed and no position is held (the sell order has been filled), and the path to open positions will run;

Step 3: Add an 「Value Assignment」 after the 「Place Order」, and re-assign value to the global variable "a":

● Path to close positions: re-assign -1 to the global variable "a" to indicate a sell order has been placed.

● Path to open positions: re-assign 1 to the global variable "a" to indicate a buy order has been placed.


Placing an order for a fixed number of shares vs for a pro rata number of shares

Here are two order scenarios: placing an order for a fixed number of shares and for shares as a percentage of cash.

Scenario 1: Placing an order for a fixed number of stocks

If you need to trade a fixed number of underlying stocks, just select "Shares" and enter a value in the "Qty" box of the 「Place Order」.

Scenario 2: Placing an order for a pro rata number of shares

If you need to trade a pro rata number of shares (e.g.,100% of available cash), you only need to select "Buyable on Cash" and enter the percentage in the "Qty" box of the 「Place Order」.


Monitoring once for every tick vs monitoring once for every certain time frame candlestick

Different users have different needs for the timing of when a signal triggers buying or selling. Here are two ways to monitor signals: monitoring once for every tick vs monitoring once for every certain time frame candlestick.

Scenario 1: Monitoring once for every tick

If you want to monitor signals once for every tick, you only need to select "Run once for every tick" in the 「Live Trading/Backtest Settings」 window.

Scenario 2: Monitoring once for every certain time frame candlestick

If you want to monitor signals once for every certain time frame candlestick, you need to select the corresponding time frame in the 「Live Trading/Backtest Settings」 window.