Pages

Subscribe:

Friday, May 27, 2011

Trading functions

Trading functions
HistoryTotal ()
OrderClose ()
OrderCloseBy ()
OrderClosePrice ()
OrderCloseTime ()
OrderComment ()
OrderCommission ()
OrderDelete ()
OrderExpiration ()
OrderLots ()
OrderMagicNumber ()
OrderModify ()
OrderOpenPrice ()
OrderOpenTime ()
OrderPrint ()
OrderProfit ()
OrderSelect ()
OrderSend ()
OrderStopLoss ()
OrdersTotal ()
OrderSwap ()
OrderSymbol ()
OrderTakeProfit ()
OrderTicket ()
OrderType ()


int HistoryTotal ()

Returns number of rows locked in account history.
Sample
int accCount;
accCount = HistoryTotal ();


bool OrderClose (int ticket, double lots, double price, int slippage, color Color = CLR_NONE)

Closes opened order and selects it.
Parameters

ticket - a unique number on the order ticket.
many - Number of the lot.
price - preferred closing price.
slippage - Value of the maximum price slippage in points.
Color - Color closing arrow chart.If parameter is absent or has a value close CLR_NONE arrow is drawn on the chart.
Sample
if (iRSI (NULL, 0,14, PRICE_CLOSE, 0)> 75)
{
OrderClose (order_id, 1, Ask, 3, red);
return (0);
}


bool OrderCloseBy (int ticket, int opposite, color Color = CLR_NONE)

Close open goal by another open opposite order.
Parameters

ticket - a unique number on the order ticket.
opposite - a unique number on reverse order ticket.
Color - Color closing arrow chart.If parameter is absent or has a value close CLR_NONE arrow is drawn on the chart.
Sample
if (iRSI (NULL, 0,14, PRICE_CLOSE, 0)> 75)
{
OrderCloseBy (order_id, opposite_id);
return (0);
}


double OrderClosePrice ()

He returned to near cost for the currently selected row.
Sample
OrderSelect (10, SELECT_BY_POS);
double price = OrderClosePrice ();
Print ("Close price for the order 10", price);


datetime OrderCloseTime ()

He returned in time to close the currently selected row. If you order close time is not equal to 0 then the objective is selected and retrieved from a closed account history.
Sample
OrderSelect (10, SELECT_BT_POS, MODE_HISTORY);
Part of the Community trade mark = OrderCloseTime ();
if (datetime> 0)
Print ("close time order 10" Community trade mark);


array OrderComment ()

Returns commentary on selected row.
Sample
string comment;
OrderSelect (10, SELECT_BY_TICKET);
Comment = OrderComment ();


double OrderCommission ()

Returns calculated fee for the currently selected order.
Sample
OrderSelect (10, SELECT_BY_POS);
Value = OrderCommission ();
Print ("Committee of 10", value);


bool OrderDelete (int ticket)

Deletes previously open pending order.
Parameters

ticket - a unique number on the order ticket.
Sample
if (Ask> var1)
{
OrderDelete (order_ticket);
return (0);
}


datetime OrderExpiration ()

Returns the expiration of the selected pending order.
Sample
int end;
OrderSelect (10, SELECT_BY_TICKET);
datetime expiration = OrderExpiration ();
Print ("Order expiration meant # 10, rock);


double OrderLots ()

It returns much value for the selected row.
Sample
OrderSelect (10, SELECT_BY_POS);
Value = OrderLots ();
Print ("lots for the order 10", value);


int OrderMagicNumber ()

It returns the magic number for the currently selected order.
Sample
OrderSelect (10, SELECT_BY_POS);
"Int" no = OrderMagicNumber ();
Print ("magic number to order 10", no);


int OrderModify (int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color = CLR_NONE)

Change of features previously opened position or pending orders.
Parameters

ticket - a unique number on the order ticket.
price - new price (for pending orders).
stoploss - New stoploss level.
takeprofit - New profit level.
expiry - expiry Order server date / time.
arrow_color - Arrow color of the pictogram chart.If parameter is absent or has a value CLR_NONE arrow is drawn on the chart.
Sample
if (TrailingStop> 0)
{
SelectOrder (1, SELECT_BY_TICKET);
if (Bid-OrderOpenPrice ())> Point * TrailingStop)
{
if (OrderStopLoss () <(Bid counts * TrailingStop))
{
OrderModify (OrderTicket (), Ask-10 * Point, Ask-35 * Point, OrderTakeProfit (), 0, blue);
return (0);
}
}
}


double OrderOpenPrice ()

Returns open price for the currently selected row.
Sample
OrderSelect (10, SELECT_BY_POS);
double price = OrderOpenPrice ();
Print ("open price for the order 10", price);


datetime OrderOpenTime ()

Returns open time for the currently selected order.
Sample
OrderSelect (10, SELECT_BY_POS);
Part of the Community trade mark = OrderOpenTime ();
Print ("open time of order 10," Community trade mark);


void OrderPrint ()

Prints selected data in the log for the selected row.
Sample
OrderSelect (10, SELECT_BY_TICKET);
OrderPrint ();


double OrderProfit ()

She returned a profit for the currently selected order.
Sample
OrderSelect (10, SELECT_BY_POS);
double profit = OrderProfit ();
Print ("Profit for the purpose 10", profit);


bool OrderSelect (int index int select = SELECT_BY_POS, int pool = MODE_TRADES)

Selects the index or ranked according tickets for further processing. OrderSend (), OrderClose () and OrderModify () function also changes the selected row. If the goal is to erase selected OrderDelete () function returns selected row.
Parameters

index - index Buy a ticket or order, depending on the second parameter.
choose - Choose flags. It may be one of the following values:
SELECT_BY_POS - index pool is in order,
SELECT_BY_TICKET - index is designed ticket.
pool - pool index Optional goal. It is used when the select parameter is SELECT_BY_POS.It can be any one of the following values:
MODE_TRADES (default) - target selected by the trading pool (open and pending orders)
MODE_HISTORY - order selected from the history pool (closed and canceled order).
Sample
OrderSelect (12.470, SELECT_BY_TICKET);
Print ("order" 12,470 open price ", OrderOpenPrice ());
Print ("order" near price is 12.470 ", OrderClosePrice ());


int OrderSend (string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment = NULL, int magic = 0, datetime expiration = 0, color arrow_color = CLR_NONE)

The main function used to open a position or set pending order. Returns a ticket order placed or -1 if failed. To check the error code using GetLastError () function.
Parameters

symbol - a symbol of trading.
cmd - Operation type. It may be one of the following values:
OP_BUY - buying position
OP_SELL - sales position
OP_BUYLIMIT - Buy limit pending position
OP_BUYSTOP - Buy stop pending position
OP_SELLLIMIT - sell limit pending position
OP_SELLSTOP - sell stop pending position.
volume - Number of the lot.
price - price of preferred trade.
slippage - Maximum price slippage in buying or selling orders.
stoploss - Stop loss level.
takeprofit - Take profit level.
Commentary - comments on the text line.
magic - the magic number order.
end - Order expiration time (for pending orders only).
arrow_color - Color at the opening of the arrow on the chart. If the parameter is absent or has a value CLR_NONE opening arrow is not drawn on the chart.
Sample
int ticket;
if (iRSI (NULL, 0,14, PRICE_CLOSE, 0) <25)
{
ticket = OrderSend (Symbol (), OP_BUY, 1, Ask, 3, Ask-25 * Point, Ask +25 * Point, "My goal # 2, 16384.0, green);
if (ticket <0)
{
Print ("OrderSend failed with error", GetLastError ());
return (0);
}
}


double OrderStopLoss ()

Returns stop loss value for the currently selected order.
Sample
OrderSelect (10, SELECT_BY_POS);
Value = OrderStopLoss ();
Print ("Stop loss of value of order 10", value);


int OrdersTotal ()

Returns market and pending orders count.
Sample
int count;
count = OrdersTotal ();


double OrderSwap ()

Returns swap value for the currently selected order.
Sample
OrderSelect (order_id, SELECT_BY_TICKET);
double swap = OrderSwap ();
Print ("replacement order #", order_id, "", swap);


array OrderSymbol ()

Return the order value for the selected symbol row.
Sample
array symbl;
OrderSelect (12, SELECT_BY_POS);
Print ("a symbol of order #", OrderTicket (), "is", OrderSymbol ());


double OrderTakeProfit ()

Return to profit for the currently selected order.
Sample
Value = OrderTakeProfit ();


int OrderTicket ()

Returns the number of tickets for the currently selected order.
Sample
int target;
OrderSelect (12, SELECT_BY_POS);
For = OrderTicket ();


int OrderType ()

Returns a type for the currently selected row.
Sample
int order_type;
OrderSelect (12, SELECT_BY_POS);
order_type = OrderType ();

0 comments:

Post a Comment