SortedByValue
- ライブラリ
- Xiaoyu Huang
- バージョン: 1.7
- アップデート済み: 7 5月 2023
- アクティベーション: 20
このライブラリは、キーと値の配列をソートするために使用されます。多くの場合、値をソートする必要があります。
Python言語のように
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);
最強の通貨はキー[4]、「GBP」
最も弱い通貨は key[0]、「JPY」です