//+------------------------------------------------------------------+
//| 스크립트 프로그램 시작 함수 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 모든 계정 주문 목록에 의한 루프
int total=OrdersTotal();
for(int i=0; i<total; i++)
{
//--- 루프 인덱스를 통해 리스트에서 주문 티켓 가져오기
ulong ticket=OrderGetTicket(i);
if(ticket==0)
continue;
//--- 주문 유형을 가져오고 선택한 주문의 실제 속성 목록에 대한 헤더를 표시합니다.
string type=OrderTypeDescription((ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE));
PrintFormat("Double properties of an active pending order %s #%I64u:", type, ticket);
//--- 헤더 아래에서 선택한 주문의 모든 실제 속성을 인쇄합니다.
OrderPropertiesDoublePrint(16);
}
/*
결과:
Double properties of an active pending order Sell Limit #2812000714:
Volume initial: 1.00
Volume current: 1.00
Price open: 145.282
StopLoss: 0.000
TakeProfit: 0.000
Price current: 145.044
StopLimit: 0.000
Double properties of an active pending order Buy Limit #2812001112:
Volume initial: 1.00
Volume current: 1.00
Price open: 144.836
StopLoss: 0.000
TakeProfit: 0.000
Price current: 145.051
StopLimit: 0.000
Double properties of an active pending order Buy Stop #2812001488:
Volume initial: 0.50
Volume current: 0.50
Price open: 1.10642
StopLoss: 0.00000
TakeProfit: 0.00000
Price current: 1.10530
StopLimit: 0.00000
Double properties of an active pending order Sell Stop #2812001712:
Volume initial: 0.50
Volume current: 0.50
Price open: 1.10374
StopLoss: 0.00000
TakeProfit: 0.00000
Price current: 1.10525
StopLimit: 0.00000
*/
}
//+------------------------------------------------------------------+
//| 주문 유형 설명을 반환 |
//+------------------------------------------------------------------+
string OrderTypeDescription(const ENUM_ORDER_TYPE type)
{
switch(type)
{
case ORDER_TYPE_BUY : return("Buy");
case ORDER_TYPE_SELL : return("Sell");
case ORDER_TYPE_BUY_LIMIT : return("Buy Limit");
case ORDER_TYPE_SELL_LIMIT : return("Sell Limit");
case ORDER_TYPE_BUY_STOP : return("Buy Stop");
case ORDER_TYPE_SELL_STOP : return("Sell Stop");
case ORDER_TYPE_BUY_STOP_LIMIT : return("Buy Stop Limit");
case ORDER_TYPE_SELL_STOP_LIMIT : return("Sell Stop Limit");
default : return("Unknown order type");
}
}
//+------------------------------------------------------------------+
//| 선택한 주문의 실제 속성을 저널에 표시 |
//+------------------------------------------------------------------+
void OrderPropertiesDoublePrint(const uint header_width=0)
{
//--- 주문 심볼과 심볼의 소수 자릿수를 가져옵니다.
string symbol = OrderGetString(ORDER_SYMBOL);
int digits = (int)SymbolInfoInteger(symbol, SYMBOL_DIGITS);
//--- 저널에 지정된 너비의 헤더로 주문할 때 초기 볼륨을 표시
OrderPropertyPrint("Volume initial:",header_width,2,ORDER_VOLUME_INITIAL);
//--- 미체결 주문량을 저널에 표시
OrderPropertyPrint("Volume current:",header_width,2,ORDER_VOLUME_CURRENT);
//--- 주문에서 지정한 가격을 저널에 표시
OrderPropertyPrint("Price open:",header_width,digits,ORDER_PRICE_OPEN);
//--- 저널에 StopLoss 레벨을 표시
OrderPropertyPrint("StopLoss:",header_width,digits,ORDER_SL);
//--- 저널에 TakeProfit 레벨을 표시
OrderPropertyPrint("TakeProfit:",header_width,digits,ORDER_TP);
//--- 저널의 주문 심볼로 현재 가격을 표시
OrderPropertyPrint("Price current:",header_width,digits,ORDER_PRICE_CURRENT);
//--- StopLimit 주문이 활성화되면 지정가 주문 가격을 저널에 표시
OrderPropertyPrint("StopLimit:",header_width,digits,ORDER_PRICE_STOPLIMIT);
}
//+------------------------------------------------------------------+
//| 주문 실제 자산 가치를 저널에 표시 |
//+------------------------------------------------------------------+
void OrderPropertyPrint(const string header, uint header_width, int digits, ENUM_ORDER_PROPERTY_DOUBLE property)
{
double value=0;
if(!OrderGetDouble(property, value))
PrintFormat("Cannot get property %s, error=%d", EnumToString(property), GetLastError());
else
{
//--- 헤더 너비가 0과 같은 함수에 전달되면 너비는 헤더 줄 크기 + 1
uint w=(header_width==0 ? header.Length()+1 : header_width);
PrintFormat("%-*s%-.*f", w, header, digits, value);
}
}
|