XMのスワップを抽出するインジケーターを作成しました。
確か前にも作った記憶があるんですが、すぐに無くしてしまうので、ブログに残しておくことにしました(´・ω・`)
インジケーターの出力結果は「MQL4\Files」にCSVファイルとして出力されます。
今回はスワップを抽出していますが、MarketInfo関数のパラメーターを変更すれば色々な情報を取得出来ますので、興味のある人はカスタマイズして使ってください。
[php] //+——————————————————————+ //| AllSymbols.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+——————————————————————+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window //+——————————————————————+ //| Custom indicator initialization function | //+——————————————————————+ int OnInit() { //— indicator buffers mapping //— return(INIT_SUCCEEDED); } //+——————————————————————+ //| Custom indicator iteration function | //+——————————————————————+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //— //— return value of prev_calculated for next call return(rates_total); } //+——————————————————————+ //| ChartEvent function | //+——————————————————————+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { int handle=FileOpen("AllSymbols.csv", FILE_CSV|FILE_WRITE, ‘,’); if(handle>0) { FileWrite(handle,"symbol,longSwap,shotSwap"); for(int i=0;i<SymbolsTotal(false)-1;i++) { string symbol = SymbolName(i,false); double lSwap = MarketInfo(symbol,MODE_SWAPLONG); double sSwap = MarketInfo(symbol,MODE_SWAPSHORT); if(MarketInfo(symbol,MODE_MARGINCALCMODE)==0) { FileWrite(handle, symbol +","+(string)lSwap +","+(string)sSwap); } } } FileClose(handle); } [/php]