├── forexDataExporter.ex5 ├── README.md └── forexDataExporter.mq5 /forexDataExporter.ex5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahdi-abbaspour-shahmarasi/forexDataExporter/HEAD/forexDataExporter.ex5 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # forexDataExporter 2 | If you want to export arbitary data for any pairs, forexDataExporter is suitable for you. 3 | It's as simple as adding an expert. 4 | -------------------------------------------------------------------------------- /forexDataExporter.mq5: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| fxDataExporter.mq5 | 3 | //| Copyright 2022, MetaQuotes Ltd. | 4 | //| https://www.m-abbaspour.ir | 5 | //| http://www.topon.ir | 6 | //+------------------------------------------------------------------+ 7 | #property copyright "Copyright 2022, MetaQuotes Ltd." 8 | #property link "https://www.m-abbaspour.ir/" 9 | #property version "1.10" 10 | 11 | #define MAX_COUNT 50 12 | //+------------------------------------------------------------------+ 13 | //| Indicators Settings | 14 | //+------------------------------------------------------------------+ 15 | 16 | input group "__ RSI Settings __"; 17 | input int ma_period = 14; 18 | input ENUM_APPLIED_PRICE applied_price_rsi = PRICE_CLOSE; 19 | //___________________________________________________________________ 20 | input group "__ 1st_MA Settings __"; 21 | input int ma_period_1st = 9; 22 | input int ma_shift_1st = 1; 23 | input ENUM_MA_METHOD ma_method_1st = MODE_EMA; 24 | input ENUM_APPLIED_PRICE applied_price_1st = PRICE_TYPICAL; 25 | //___________________________________________________________________ 26 | input group "__ 2nd_MA Settings __"; 27 | input int ma_period_2nd = 26; 28 | input int ma_shift_2nd = 1; 29 | input ENUM_MA_METHOD ma_method_2nd = MODE_EMA; 30 | input ENUM_APPLIED_PRICE applied_price_2nd = PRICE_TYPICAL; 31 | //___________________________________________________________________ 32 | input group "__ 3rd_MA Settings __"; 33 | input int ma_period_3rd = 52; 34 | input int ma_shift_3rd = 1; 35 | input ENUM_MA_METHOD ma_method_3rd = MODE_EMA; 36 | input ENUM_APPLIED_PRICE applied_price_3rd = PRICE_TYPICAL; 37 | //___________________________________________________________________ 38 | input group "__ 4th_MA Settings __"; 39 | input int ma_period_4th = 104; 40 | input int ma_shift_4th = 1; 41 | input ENUM_MA_METHOD ma_method_4th = MODE_EMA; 42 | input ENUM_APPLIED_PRICE applied_price_4th = PRICE_TYPICAL; 43 | //___________________________________________________________________ 44 | <<<<<<< HEAD 45 | input group "__MA_200 Settings__"; 46 | input int ma_shift_200 = 1; 47 | input ENUM_MA_METHOD ma_method_200 = MODE_SMA; 48 | input ENUM_APPLIED_PRICE applied_price_200 = PRICE_CLOSE; 49 | //___________________________________________________________________ 50 | input group "__Ichimouko Settings__"; 51 | input int tk_period = 9; 52 | input int kj_period = 26; 53 | input int senkou_span_b = 52; 54 | input int shift = 0; 55 | //___________________________________________________________________ 56 | input group "__ 5th_MA Settings __"; 57 | input int ma_period_5th = 200; 58 | input int ma_shift_5th = 1; 59 | input ENUM_MA_METHOD ma_method_5th = MODE_EMA; 60 | input ENUM_APPLIED_PRICE applied_price_5th = PRICE_TYPICAL; 61 | 62 | //+------------------------------------------------------------------+ 63 | //| Expert initialization function | 64 | //+------------------------------------------------------------------+ 65 | int currentCandleNo=0; 66 | int OnInit() 67 | { 68 | currentCandleNo=iBars(Symbol(),PERIOD_CURRENT); 69 | int f=FileOpen(Symbol()+"_"+EnumToString(Period())+".csv",FILE_READ|FILE_WRITE|FILE_TXT); 70 | FileSeek(f,0,SEEK_END); 71 | FileWrite(f,"DateTime,Open,High,Low,Close,Ma"+string(ma_period_1st)+",MA"+string(ma_period_2nd)+",MA"+string(ma_period_3rd)+",MA"+string(ma_period_4th)+",MA"+string(ma_period_5th)+",RSI,TENKAN,KIJUN,SPAN_A,SPAN_B,CHIKOU_SPAN"); 72 | FileFlush(f); 73 | FileClose(f); 74 | return(INIT_SUCCEEDED); 75 | } 76 | //+------------------------------------------------------------------+ 77 | //| Expert tick function | 78 | //+------------------------------------------------------------------+ 79 | void OnTick() 80 | { 81 | int number=iBars(Symbol(),PERIOD_CURRENT); 82 | if(number!=currentCandleNo) 83 | { 84 | datetime dt= iTime(Symbol(),PERIOD_CURRENT,1); 85 | double open = iOpen(Symbol(),PERIOD_CURRENT,1); 86 | double close = iClose(Symbol(),PERIOD_CURRENT,1); 87 | double high = iHigh(Symbol(),PERIOD_CURRENT,1); 88 | double low = iLow(Symbol(),PERIOD_CURRENT,1); 89 | 90 | double ma_1st=iMA(Symbol(), PERIOD_CURRENT,ma_period_1st,ma_shift_1st,ma_method_1st,applied_price_1st); 91 | double movingAverageValues_1st[]; 92 | ArraySetAsSeries (movingAverageValues_1st, true); 93 | CopyBuffer(ma_1st,0, 0, 100, movingAverageValues_1st); 94 | 95 | double ma_2nd=iMA(Symbol(), PERIOD_CURRENT,ma_period_2nd,ma_shift_2nd,ma_method_2nd,applied_price_2nd); 96 | double movingAverageValues_2nd[]; 97 | ArraySetAsSeries (movingAverageValues_2nd, true); 98 | CopyBuffer(ma_2nd,0, 0, 100, movingAverageValues_2nd); 99 | 100 | double ma_3rd=iMA(Symbol(), PERIOD_CURRENT,ma_period_3rd,ma_shift_3rd,ma_method_3rd,applied_price_3rd); 101 | double movingAverageValues_3rd[]; 102 | ArraySetAsSeries (movingAverageValues_3rd, true); 103 | CopyBuffer(ma_3rd,0, 0, 100, movingAverageValues_3rd); 104 | 105 | double ma_4th=iMA(Symbol(), PERIOD_CURRENT,ma_period_4th,ma_shift_4th,ma_method_4th,applied_price_4th); 106 | double movingAverageValues_4th[]; 107 | ArraySetAsSeries (movingAverageValues_4th, true); 108 | CopyBuffer(ma_4th,0, 0, 100, movingAverageValues_4th); 109 | 110 | double ma_5th=iMA(Symbol(), PERIOD_CURRENT,ma_period_5th,ma_shift_5th,ma_method_5th,applied_price_5th); 111 | double movingAverageValues_5th[]; 112 | ArraySetAsSeries (movingAverageValues_5th, true); 113 | CopyBuffer(ma_5th,0, 0, 100, movingAverageValues_5th); 114 | 115 | double rsi=iRSI (Symbol(),PERIOD_CURRENT,ma_period,applied_price_rsi); 116 | double rsiArray[]; 117 | ArraySetAsSeries(rsiArray, true); 118 | CopyBuffer(rsi,0,0,100,rsiArray); 119 | 120 | double ichi=iIchimoku(Symbol(), PERIOD_CURRENT, tk_period, kj_period, senkou_span_b); 121 | double tenkan[]; 122 | double kijun[]; 123 | double span_a[]; 124 | double span_b[]; 125 | double chikou_span[]; 126 | ArraySetAsSeries(tenkan, true); 127 | ArraySetAsSeries(kijun, true); 128 | ArraySetAsSeries(span_a, true); 129 | ArraySetAsSeries(span_b, true); 130 | ArraySetAsSeries(chikou_span, true); 131 | 132 | CopyBuffer(ichi, 0, 0, MAX_COUNT,tenkan); 133 | //double value = NormalizeDouble(tenkan[shift],_Digits); 134 | 135 | CopyBuffer(ichi, 1, 0, MAX_COUNT, kijun); 136 | //double value = NormalizeDouble(kijun[pShift], _Digits); 137 | 138 | CopyBuffer(ichi, 2, 0, MAX_COUNT, span_a); 139 | //double value = NormalizeDouble(span_a[pShift], _Digits); 140 | 141 | CopyBuffer(ichi, 3, 0, MAX_COUNT, span_b); 142 | //double value = NormalizeDouble(span_b[pShift], _Digits); 143 | 144 | CopyBuffer(ichi, 4, 0, MAX_COUNT, chikou_span); 145 | //double value = NormalizeDouble(chikou_span[pShift], _Digits); 146 | 147 | int h=FileOpen("data.csv",FILE_READ|FILE_WRITE|FILE_TXT); 148 | 149 | int h=FileOpen(Symbol()+"_"+EnumToString(Period())+".csv",FILE_READ|FILE_WRITE|FILE_TXT); 150 | 151 | if(h==INVALID_HANDLE) 152 | { 153 | Alert("Error opening file"); 154 | return; 155 | } 156 | FileSeek(h,0,SEEK_END); 157 | FileWrite(h,string(dt)+","+DoubleToString(open)+"," 158 | +DoubleToString(high)+"," 159 | +DoubleToString(low)+"," 160 | +DoubleToString(close)+"," 161 | +DoubleToString(movingAverageValues9[0])+"," 162 | +DoubleToString(movingAverageValues26[0])+"," 163 | +DoubleToString(movingAverageValues52[0])+"," 164 | +DoubleToString(movingAverageValues104[0])+"," 165 | +DoubleToString(movingAverageValues200[0])+"," 166 | +DoubleToString(tenkan[0])+"," 167 | +DoubleToString(kijun[0])+"," 168 | +DoubleToString(span_a[0])+"," 169 | +DoubleToString(span_b[0])+"," 170 | +DoubleToString(chikou_span[0])); 171 | +DoubleToString(movingAverageValues_1st[0])+"," 172 | +DoubleToString(movingAverageValues_2nd[0])+"," 173 | +DoubleToString(movingAverageValues_3rd[0])+"," 174 | +DoubleToString(movingAverageValues_4th[0])+"," 175 | +DoubleToString(movingAverageValues_5th[0])+"," 176 | +DoubleToString(rsiArray[0])); 177 | FileFlush(h); 178 | FileClose(h); 179 | currentCandleNo=number; 180 | } 181 | Comment("Number Of Candle:"+string(number)); 182 | } 183 | //+------------------------------------------------------------------+ 184 | --------------------------------------------------------------------------------