SortedByValue
- 라이브러리
- Xiaoyu Huang
- 버전: 1.7
- 업데이트됨: 7 5월 2023
- 활성화: 20
이 라이브러리는 키 및 값 배열을 정렬하는 데 사용되며 종종 값을 정렬해야 합니다.
파이썬 언어처럼
sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]))
가져오기 기능
사용 시나리오의 예
1. 그리드 EA 주문은 시가에 따라 정렬됩니다.
void SortedByOpenPride() { long OrderTicketBuffer[]; double OpenPriceBuffer[]; for(int i = PositionsTotal()-1; i>=0; i--) { if(m_position.SelectByIndex(i)) { OrderTicketBuffer[i] = long(m_position.Ticket()); OpenPriceBuffer[i] = m_position.PriceOpen(); } } SortedByDouble(OrderTicketBuffer,OpenPriceBuffer); }
최상위 주문의 티켓은 OrderTicketBuffer[ArraySize(OrderTicketBuffer)-1]입니다.
하단 주문의 티켓은 OrderTicketBuffer[0]입니다.
2. 통화 강도로 정렬
string key[5]; double value[5]; key[0] = "USD"; key[1] = "EUR"; key[2] = "GBP"; key[3] = "AUD"; key[4] = "JPY"; value[0] = 1.2; value[1] = 2.5; value[2] = 3.3; value[3] = 1.1; value[4] = 0.8; SortedByDouble(key,value);
가장 강력한 통화는 key[4], "GBP"입니다.
가장 약한 통화는 key[0], "JPY"입니다.