order (int type): int
User-supplied function that is called by the trade engine every time when Zorro enters or exits a trade. Can be used to access external broker APIs, control external trade
platforms by sending key strokes or mouse clicks, or just pop up a message for manually entering or exiting a trade.
Parameters:
type - 1 for entering, 2 for exiting a trade.
Returns:
0 when the trade could not be opened or closed, 1 otherwise.
Remarks:
- If an order function is defined in the script, it
replaces the trade functions of the selected broker plugin.
- All trade variables f.i. for determining the asset and algo are available in the order function.
Example:
int order(int type)
{
string bs = "Buy";
if(type == 2) bs = "Sell";
string ls = "Long";
if(TradeIsShort) ls = "Short";
play("alert.wav");
return msg("%s %s!",bs,ls);
}
See also:
Brokers, enterShort/Long, exitShort/Long, msg, login, API, broker plugin, user supplied functions
► latest
version online