Install

  1. แตกไฟล์ SmartBridgePython.zip นำไฟล์ด้านในทั้งหมดไปไว้ที่โฟลเดอร์โปรเจคของคุณที่มีไฟล์ .py
  2. ในโค๊ดที่จะใช้ DLL ให้ทำการ import SmartBridgePlugin_python37_x64

มีสามฟังชั่นที่ต้องเรียกใช้งานเป็นอันดับแรกคือ SetServer(string), SetPort(int) และ SetKey(string)

Setup

SetServer

            Set IP for connect to smart bridge server.

                        string SetServer(string servername);

            Parameter

                        servername– IP or URL for connect to Smart Bridge server.

            Returned value

                        – Smart Bridge Server Address: servername

            Example:

                        SetServer(“127.0.0.1”);

SetPort

            Set port for connect to smart bridge server.

                        string SetPort(int port);

            Parameter

                        port– for connect to Smart Bridge server.

            Returned value

                        – Smart Bridge Server Port: port

            Example:

                        SetPort(5500);

SetKey

            Set key for connect to smart bridge server.

                        string SetKey(string key);

            Parameter

                        – Smart Bridge users license key: key

            Returned value

                        – 1 if valid key

– 0 if invalid key

            Example:

                        SetKey(“ALannisterAlwaysPaysHisDebts”);

Open an order/place a pending

OrderSend

The main function used to open market or place a pending order.

string OrderSend(string symbol, string cmd, string comment, int volume, double

price, int slippage, double sl, double tp,intmagicnumber);

Parameter:

-symbol

Symbol for trading.

-cmd

Operation type.It can be any of the following values

OP_BUY Buy operation
OP_SELL Sell operation
OP_BUYLIMIT Buy limit pending order
OP_SELLLIMIT Sell limit pending order
OP_BUYSTOP Buy stop pending order
OP_SELLSTOP Sell stop pending order
  • comment

Order comment text. Last part of the comment may be changed by server.

  • volume

Number of lots.

  • price

Order price.

  • slippage

Maximum price slippage for buy or sell orders.

  • sl

Stop loss level.

  • tp

Take profit level.

  • magic

Order magic number. May be used as user defined identifier.

            Returned value:

  • Number of the ticket assigned to the order by the trade server.
  • 0 or Error Message if fail.

Example:

ticket = OrderSend(“S50M17”, “OP_BUY”, “Amibroker”, 1, 963.9, 3, 0, 0, 0);

printf(“Send order success ticket = ” + ticket + “\n”);

Information

AccountInfo

Get all account information.

string AccountInfo();

Parameter:

            Returned value:

-The account’s info separate by comma ( , )
Trade server name, Current profit of an account in the deposit currency, The current account number, Client name, Account margin used in the deposit currency, Account leverage, Free margin of an account in the deposit currency, Account equity in the deposit currency, Name of a company that serves the account, Account balance in the deposit currency, Allowed trade for the current account, Account trade mode

-Error message or “0” if fail.

Example

accInfo = AccountInfo();

OrderActive

Get all opened order.

string OrderActive();

Parameter:

 Returned value:

Ticket number of the order, Open time of the order, Order operation type of the order, Amount of lots of the order, Symbol name of the order, Open price of the order, Stop loss value of the order, Take profit value of the order, Current price of the order, Calculated commission of the order, Swap value of the order, Returns profit of the order, Comment of the order, Number of all opened order

-Error message or “0” if fail.

Example

OpenedOrders = OrderActive();

OrderPending

Get all opened pending order

string OrderPending();

Parameter:

Returned value:

Ticket number of the order, Open time of the order, Order operation type of the order, Amount of lots of the order, Symbol name of the order, Open price of the order, Stop loss value of the order, Take profit value of the order, Current price of the order, Comment of the order, Number of all opened pending order

-Error message or “0” if fail.

Closing order, deleting pending or modifying

OrderClose

Closes opened order

int OrderClose(int ticket, int voulume, int slippage);

Parameter:

  • ticket

Unique number of the order ticket.

  • voulume

Number of lots.

  • slippage

Value of the maximum price slippage in points.

            Returned value:

  • Returns 1 if successful.
  • Error message or “0” if fail.

Example

ret = OrderClose(12345, 1, 0);

printf(“Retutn code = ” + ret + “\n”);

ClosePositionAll

Closes all opened order.

string ClosePositionAll();

Parameter:

 Returned value:

  • Returns 1 if successful.
  • Error message or “0” if fail.

Example

ret = ClosePositionAll();

printf(“Retutn code = ” + ret + “\n”);

OrderDelete

Deletes previously opened pending order

string OrderDelete(int ticket);

Parameter:

-ticket

-Unique number of the order ticket.

Returned value:

  • Returns 1 if successful.
  • Error message or “0” if fail.

Example

ret = OrderDelete(12345);

printf(“Retutn code = ” + ret + “\n”);

ClosePendingAll

Deletes all opened pending order

string ClosePendingAll();

Parameter:

– 

Returned value:

  • Returns 1 if successful.
  • Error message or “0” if fail.

Example:

ret = ClosePendingAll();

printf(“Retutn code = ” + ret + “\n”);

CloseAll

Closes all opened order and deletes all opened pending order

int CloseAll();

Parameter:

Returned value:

  • Returns 1 if successful.
  • Error message or “0” if fail.

Example:

ret = CloseAll();

printf(“Retutn code = ” + ret + “\n”);

OrderModify

Modification of characteristics of the previously opened or pending orders

int OrderModify(int ticket,double price,double sl,double tp);

Parameter:

  • ticket

Unique number of the order ticket.

  • price

Open price of the order.

  • sl

Stop loss level.

  • tp

Take profit level.

  Returned value:

  • Returns 1 if successful.
  • Error message or “0” if fail.

Example

ret = OrderModify(12345, 900, 850.5, 905.5);

printf(“Retutn code = ” + ret + “\n”);