Time Frame Code (TF Code)
Set the close price, stop-loss execution time frame, and Fibonacci retracement ratio.

The time frame code (TF code) is a code you can send from your mobile phone to adjust the time frame in which you want to execute the stop-loss. It is placed in the last decimal of the stop-loss price. For a five-decimal EURUSD buy ticket, the code between 0.00001 and 0.00008 will be mapped to timeframes from M1 to W1.

- If you want to set 1.00000 as your stop-loss on EURUSD with a timeframe of M5, simply add 0.00002 to 1.00000 and send 1.00002.
- If you want to set a stop-loss of 150.50 on USDJPY with a timeframe of M15, you would send 150.53 (150.50 + 0.03).
Regardless of whether the broker or trading platform uses 2, 3, or 5 decimals, we will use the last decimal as the timeframe code. The corresponding timeframes are listed in the table below:
| TF code (last decimal) | Timeframe |
|---|---|
| 0 | Direct enter with auto lot size calculation |
| 1 | M1 |
| 2 | M5 |
| 3 | M15 |
| 4 | M30 |
| 5 | H1 |
| 6 | H4 |
| 7 | D1 |
| 8 | W1 |
| 9 | Clear the setting of stoploss, take profit, TF code, and FB code |
Codes 1-8: Time Frame Code
Codes 1-8 represent the time frame code, which indicates the stop-loss execution timeframe. For example, if you send the stop-loss price for EURUSD as 1.38532, the last decimal (code 2) will be interpreted as the execution time frame. Here is how the program separates your stop-loss from the time frame code:
- Time frame: It takes the last decimal (0.00002) from 1.38532 and interprets it as the M5 timeframe.
- Close-price stop-loss: It rounds down the stop-loss price (1.38532 → 1.38530) and stores it as the close-price stop-loss value.
- Execution: Once the close price drops below 1.38530, the trade will be closed.
- Time frame: It takes the last decimal (0.00002) from 1.38532 and interprets it as the M5 timeframe.
- Close-price stop-loss: It rounds up the stop-loss price (1.38532 → 1.38540) and stores it as the close-price stop-loss value.
- Execution: When the close price rises above 1.38540 on the M5 timeframe, the trade will be closed.
Interpretation of the Close Price Stop-Loss
Regardless of whether a product has 2 or 3 decimal places, we use the last decimal as the time frame code. After receiving the stop-loss from the user, this EA will first interpret the last decimal as the time frame code. It then calculates the close price stop-loss by rounding down the last decimal for buy orders and rounding up the last decimal for sell orders. Below are examples of the final time frame and close price stop-loss for XAUUSD and USDJPY as calculated by Cosy Trader.
| Currency/stop-loss price | TF code/time frame | Buy close price stop-loss | Sell close price stop-loss |
|---|---|---|---|
| USDJPY/154.535 | 5/H1 | 154.530 | 154.540 |
| XAUUSD/2381.23 | 3/M15 | 2381.20 | 2381.30 |
| XAUUSD/2381.232 | 2/M5 | 2381.230 | 2381.240 |
You can quickly adjust the time frame code by tapping the "+" and "-" buttons next to the stop-loss price in your MT4 app.

- Time frame code: The last decimal of the stop-loss.
- Close stop-loss price: For buy tickets, it is the rounded-down stop-loss price; for sell tickets, it is the rounded-up stop-loss price.
Code 0 and Code 9
Since there is no mapped time frame for code 0 and code 9, here we illustrate how these codes work. Please note, both codes only apply to pending tickets.
Code 0: Direct Market Entry Code
Code 0 triggers a direct market order based on the pending order you send. You might wonder why not just open a direct buy or sell order. The reason is that this utility offers the advantage of calculating the precise lot size for you, providing better risk control. Sending a direct market order is a two-step process: first, you need to send a pending ticket with any lot size, and then send the TF=0 code.
You can take a look at [B2] Direct Market Entry for more detailed information.