> For the complete documentation index, see [llms.txt](https://hdsd.dnse.com.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hdsd.dnse.com.vn/san-pham-dich-vu/ami-x/cac-cau-lenh-api-de-dat-lenh-qua-ami-x/1.-huong-dan-chi-tiet-cac-cau-lenh.md).

# 1. Hướng dẫn chi tiết các câu lệnh

Đoạn code AFL đơn giản dưới đây giúp bạn phát lệnh tự động từ AmiBroker sang Ami X qua phương thức GET:

Đoạn mã:

```
// ========================================================
// CODE AFL ĐẶT LỆNH TỰ ĐỘNG QUA AMI X (GET METHOD)
// ========================================================
Account = "0001177065";  // Thay bằng số tiểu khoản của bạn
LoanID  = "2403";        // Thay bằng mã gói vay
Symbol  = "VN30F1M";
Vol     = "1";

// Cấu hình điều kiện Buy/Sell của chiến thuật
BuyCondition  = Cross( FastMA, SlowMA ); 
SellCondition = Cross( SlowMA, FastMA );

// Hàm gửi request GET tới Ami X
function SendGetOrder( side, priceVal )
{
    local url;
    url = "http://localhost:7979/trade?side=" + side + 
          "&symbol=" + Symbol + 
          "&price=" + priceVal + 
          "&account=" + Account + 
          "&loan=" + LoanID + 
          "&volume=" + Vol;
          
    ihttpGet( url ); // Gửi request GET
}

// Bắt tín hiệu đặt lệnh
if( LastVisAction == 1 ) 
{
    if( BuyCondition )
    {
        SendGetOrder( "NB", "1300" ); // Đặt Long giá 1300
    }
    
    if( SellCondition )
    {
        SendGetOrder( "NS", "1300" ); // Đặt Short giá 1300
    }
}

```
