1. OrderSend() call initiates an Order.
2. The Order then initiates a Deal and then Order is closed.
3 On acceptance of Deal by Broker's server, a Symbol Position is opened and then Deal is closed.
ORDER_MAGIC and DEAL_MAGIC would be used in HistorySelect as part of closed Order or Deal selection process.
HistorySelect() Example:
double LastDealPrice() // Last Deal open price for chart symbol
{
uint total=0;
long ticket;
string symbol;
long magic;
HistorySelect(0,TimeCurrent());
total=HistoryDealsTotal();
for(uint i=0;i <total; i++)
{
ticket=HistoryDealGetTicket(i);
symbol=HistoryDealGetString(ticket,DEAL_SYMBOL);
magic=HistoryDealGetInteger(ticket,DEAL_MAGIC);
if( symbol==Symbol() && magic==MagicNumber)
{
Lprice=HistoryDealGetDouble(ticket,DEAL_PRICE);
}
}
return(Lprice);
}
POSITION_MAGIC is used in current open Position selection process.
PositionSelect() example:
int CurPosLots() // total lots in current symbol position
{
int total=PositionsTotal();
double lots=0;
for (int cnt=0; cnt<total; cnt++)
{
if(PositionSelect(Sysbol()) )
{
if(PositionGetInteger(POSITION_MAGIC)==MagicNumber)
{
lots=PositionGetDouble(POSITION_VOLUME);
}
}
}
return(lots);
}
No comments:
Post a Comment