Ice

46
// ตัวอย่างการเปิดคำสั่งซื้อทอง
void OpenBuyOrder() {
double lotSize = 0.1; // ขนาดล็อต
double stopLoss = Bid - 50 * Point; // ตั้ง Stop Loss
double takeProfit = Bid + 100 * Point; // ตั้ง Take Profit
int ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 2, stopLoss, takeProfit, "Buy Order", 0, 0, Blue);
if(ticket < 0) {
Print("Error in opening buy order: ", GetLastError());
} else {
Print("Buy order opened successfully with ticket #", ticket);
}
}

// ตัวอย่างการเปิดคำสั่งขายทอง
void OpenSellOrder() {
double lotSize = 0.1; // ขนาดล็อต
double stopLoss = Ask + 50 * Point; // ตั้ง Stop Loss
double takeProfit = Ask - 100 * Point; // ตั้ง Take Profit
int ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, 2, stopLoss, takeProfit, "Sell Order", 0, 0, Red);
if(ticket < 0) {
Print("Error in opening sell order: ", GetLastError());
} else {
Print("Sell order opened successfully with ticket #", ticket);
}
}

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.