ok. Sorry for my inglish =)))
MT4 to Excel through Excel RTD (Finally!) 609 replies
MT4 export to Excel? 8 replies
How do you Export MT4 price to Excel? 7 replies
Export to Excel 6 replies
Export OHLC to Excel 4 replies
DislikedHi Hanover. I appreciate your work, thanks again =)
I came after viewing two small problem ..
1. Updated data every second of it is unnecessary, and I need depending on the timeframe (if H1-once an hour, if H4-every four hours, and so on).
2. MAСD in the sixth column should not be -1 1, and must be at the histogram, such as 0.003, 0.0005, - 0.003, etc in the original form at all).
If possible please сorrect it plz....Ignored
//+------------------------------------------------------------------+ //| Output History alex indicator.mq4 | //+------------------------------------------------------------------+ #property indicator_chart_window #include <hanover --- function header.mqh> extern string CurrencyPairs = ""; extern string TimeFrames = ""; extern bool DifferentSubfolderPerTimeFrame = false; extern int LookbackBars = 100; extern bool DescendingDateTimeOrder = false; extern bool OutputHeaderLine = true; extern string FieldSeparator = ","; extern bool EncloseValuesInQuotes = false; extern string DateTimeFormat = "M/D/Y,H:I"; extern string PriceFormat = "T3.5"; extern string PriceFormatJPYpairs = "T5.3"; extern string VolumeFormat = "T10"; extern string MACDFormat = "T-3.6"; extern string MACDParameters = "12,26,9"; [color=Red][b]extern string CIIFormat = "T-3"; extern string CIIParameters = "55,0.5,3,0"; [/b][/color] string P[40],T[9], Quote; int handle, np, nt, mp[3]; [color=Red][b]double cii[4];[/b][/color] datetime prev_time; //+------------------------------------------------------------------+ int init() { //+------------------------------------------------------------------+ StrToIntegerArray(MACDParameters,mp); [color=Red][b] StrToDoubleArray(CIIParameters,cii);[/b][/color] if (StringLen(CurrencyPairs) < 1) CurrencyPairs = Symbol(); if (StringLen(TimeFrames) < 1) TimeFrames = TFToStr(Period()); if (LookbackBars < 1) LookbackBars = 999999; np = StrToStringArray(CurrencyPairs,P); nt = StrToStringArray(TimeFrames,T); Quote = ""; if (EncloseValuesInQuotes) Quote = "x22"; prev_time = -9999; process_hist(); return(0); } //+------------------------------------------------------------------+ int deinit() { //+------------------------------------------------------------------+ return(0); } //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ if (prev_time != Time[0]) { process_hist(); prev_time = Time[0]; } return(0); } //+------------------------------------------------------------------+ int process_hist() { //+------------------------------------------------------------------+ for (int i=0; i<np; i++) { for (int j=0; j<nt; j++) { out_hist(ExpandCcy(P[i]),StrToTF(T[j])); } } return(0); } //+------------------------------------------------------------------+ int out_hist(string ccy, int tf) { //+------------------------------------------------------------------+ string fname = ccy + "," + TFToStr(tf) + ".csv"; if (DifferentSubfolderPerTimeFrame) fname = "TF-" + TFToStr(tf) + "\" + ccy + "," + TFToStr(tf) + ".csv"; handle = FileOpen(fname, FILE_CSV|FILE_WRITE, ','); if (handle<1) return(0); if (OutputHeaderLine) FileWrite(handle,"Date,Time,Open,High,Low,Close,Volume,MACD histogram"); if (DescendingDateTimeOrder) { for (int i=0; i<MathMin(LookbackBars,iBars(ccy,tf)); i++) { out_line(ccy,tf,i); } } else { for (i=MathMin(LookbackBars-1,iBars(ccy,tf)-1); i>=0; i--) { out_line(ccy,tf,i); } } FileClose(handle); return(0); } //+------------------------------------------------------------------+ int out_line(string ccy, int tf, int i) { //+------------------------------------------------------------------+ string OHLCFormat = PriceFormat; if (StringFind(ccy,"JPY") >= 0) OHLCFormat = PriceFormatJPYpairs; FileWrite(handle, Quote + DateToStr(iTime(ccy,tf,i),DateTimeFormat) + Quote + FieldSeparator + Quote + NumberToStr(iOpen(ccy,tf,i),OHLCFormat) + Quote + FieldSeparator + Quote + NumberToStr(iHigh(ccy,tf,i),OHLCFormat) + Quote + FieldSeparator + Quote + NumberToStr(iLow(ccy,tf,i),OHLCFormat) + Quote + FieldSeparator + Quote + NumberToStr(iClose(ccy,tf,i),OHLCFormat) + Quote + FieldSeparator + Quote + NumberToStr(iVolume(ccy,tf,i),VolumeFormat) + Quote + FieldSeparator + Quote + NumberToStr(iOsMA(ccy,tf,mp[0],mp[1],mp[2],0,i),MACDFormat) + Quote [color=Red][b] + FieldSeparator + Quote + NumberToStr(iCustom(ccy,tf,"to_ind_CandlCode_II",cii[0],cii[1],cii[2],cii[3],0,i),CIIFormat) + Quote [/b][/color]// you can easily add more columns here using MQL4 functions like iMA, iRSI, iBands, iCustom, etc (simply copy the line above as a 'model') ); return(0); } #include <hanover --- extensible functions.mqh>
Disliked+ FieldSeparator + Quote + NumberToStr(iCustom(ccy,tf,"to_ind_ CandlCode_II",CIIParametrs,2,i),CIIFormat) + Quote //= shutdown terminal
1. i think, "to_ind_ CandlCode_II" is bad.
2. i take original CandleCode indicator //= shutdown terminalIgnored
Date,Time,Open,High,Low,Close,Volume,MACD histogram 12/26/2012,20:00,1.32190,1.32285,1.32185,1.32283,3214,0.000553,102 12/27/2012,00:00,1.32284,1.32456,1.32240,1.32343,3848,0.000644,89 12/27/2012,04:00,1.32341,1.32524,1.32234,1.32497,4602,0.000771,101 12/27/2012,08:00,1.32491,1.32749,1.32486,1.32602,7438,0.000875,110 12/27/2012,12:00,1.32603,1.32838,1.32102,1.32203,10710,0.000594,13 12/27/2012,16:00,1.32198,1.32407,1.32015,1.32373,6842,0.000467,100 12/27/2012,20:00,1.32374,1.32534,1.32291,1.32484,4951,0.000419,105 12/28/2012,00:00,1.32480,1.32501,1.32371,1.32432,4056,0.000317,37 12/28/2012,04:00,1.32433,1.32567,1.32387,1.32508,4160,0.000266,105 12/28/2012,08:00,1.32505,1.32523,1.31659,1.31805,10266,-0.000295,4 12/28/2012,12:00,1.31806,1.32380,1.31736,1.32217,9991,-0.000391,125 12/28/2012,16:00,1.32209,1.32272,1.32085,1.32219,5092,-0.000436,88 12/28/2012,20:00,1.32214,1.32241,1.32152,1.32161,1627,-0.000474,38 12/30/2012,20:00,1.32115,1.32320,1.32091,1.32255,1820,-0.000428,106 12/31/2012,00:00,1.32260,1.32345,1.32039,1.32133,3770,-0.000462,25 12/31/2012,04:00,1.32130,1.32145,1.31824,1.31912,4462,-0.000610,5 12/31/2012,08:00,1.31909,1.31997,1.31721,1.31838,7090,-0.000725,40 12/31/2012,12:00,1.31841,1.32282,1.31803,1.31811,9107,-0.000767,46 12/31/2012,16:00,1.31809,1.32145,1.31734,1.31956,8240,-0.000688,109 12/31/2012,20:00,1.31956,1.32059,1.31821,1.31821,2497,-0.000692,27 01/01/2013,20:00,1.32027,1.32193,1.31874,1.31975,2041,-0.000542,45 01/02/2013,00:00,1.31975,1.32993,1.31918,1.32858,7863,0.000223,121 01/02/2013,04:00,1.32856,1.32935,1.32524,1.32735,8400,0.000680,24 01/02/2013,08:00,1.32735,1.32912,1.32319,1.32490,13701,0.000804,12 01/02/2013,12:00,1.32495,1.32795,1.32371,1.32393,10632,0.000771,30 01/02/2013,16:00,1.32394,1.32422,1.31567,1.31752,8630,0.000233,4 01/02/2013,20:00,1.31756,1.31905,1.31755,1.31835,4193,-0.000126,106 01/03/2013,00:00,1.31836,1.31890,1.31240,1.31386,5056,-0.000715,8 01/03/2013,04:00,1.31385,1.31527,1.31321,1.31341,4872,-0.001161,42 01/03/2013,08:00,1.31343,1.31695,1.30940,1.31129,11350,-0.001591,28 01/03/2013,12:00,1.31132,1.31155,1.30823,1.30951,11706,-0.001883,20 01/03/2013,16:00,1.30951,1.31206,1.30577,1.30612,8074,-0.002173,14
Disliked1. This indicator ..... code calculates the candle chart that looks like this: 1111110 or 0011000, and then converts it into a line that looks like 65,35,75 and so on. Can you change the display so that it gives value at all timeframes 1111110,
0011000
1010111 etc which is written to a new file ?Ignored
Body Color
1 - bullish candle (closing price above the opening price)
0 - bearish candle (close is below the open price)
For bullish candlestick:
00 - there is no body (doji)
01 - a small body
10 - the average body
11 - a great body
For a bearish candle
11 - body missing (doji)
10 - a small body
01 - the average body
00 - a great body
The size of the upper shadow
00 - no shadow
01 - a small shadow
10 - the shadow of medium size
11 - big shadow
The size of the lower shadow
11 - no shadow
10 - a small shadow
01 - the shadow of medium size
00 - big shadow
If you paint, you will get this expression:
D = X1 * 20 + X2 * 21 + X3 * 22 + X4 * 23 + X5 * 24 + X6 * 25 + X7 * 26
where D - decimal candle;
n - the position number in binary code, from left to right;
Xn - a number that is at n.
The formula is very simple and without any difficulty you can use to create a technical indicator or advisor (trading robot). But there is one very important detail that the author mentions only in passing the formula - how to determine the size of the body and the shadows. Usually this is done by eye, but we did want to eliminate any subjectivity, is not it?
Estimate the size of the components candles are two basic ways. First - is to set strict limits in points for small, medium and large sizes. For example, if the upper shadow of X to Y points, it is - a small shadow, if Y to Z - average, over Z points - great. Also sets the maximum size of the body and the shadows in which they can be called absent, for example, 2 points. The disadvantage of this method is that it does not reflect the current market volatility. The X, Y and Z, which are suitable for small size candles can not be applied to large candles. If today is a shadow in the 20-point looks small, tomorrow it might be too big. To solve this problem, compare the size of the body and the shadows under consideration candles with the average size of the relevant parts of candles made for a certain time period. This is done as follows:
1. Choose the period. As we compare the candle with the candles we see in the chart, it is wise to select a period equal to the number of candles that fit into this schedule.
2. We expect the average size of the upper shadow avgHS, lower shadow and body avgLS avgB. How do you know.
3. We expect the size of the border "small", "medium", "large" for the body, the upper and lower shadows, starting with the values, respectively avgB, avgHS and avgLS. To estimate the size of the body, it looks like this:
avgB - X% avgB = <«average» <avgB + X% avgB
avgB + X% avgB = <«big»
maximum size for the "missing" body <"small» <avgB - X% avgB
where X% avgB - X percent of the value of avgB.
DislikedHi Hanover, I'm using your "out_hist" indicator to extract certain indicator values to excel. I managed to add most of the things I want however got stuck with Moving Average of an Indicator. I figured out I need to use iMAOnArray but don't have enough programming knowledge to create the array or where to place it exactly. I think it should be something like; iMAOnArray(MOMENTUM_25,ccy,tf,12,0,MODE_SMA,i) But as I mentioned I fail to create MOMENTUM_25. Can you please help me to add 12 periods Simple Moving Average of 25 periods Momentum? This...Ignored
//+------------------------------------------------------------------+ int out_hist(string ccy, int tf) { //+------------------------------------------------------------------+ string fname = ccy + "," + tf + ".csv"; // Same folder for each TF (...expertsfiles) //string fname = "TF-" + tf + "" + ccy + "," + tf + ".csv"; // Different subfolder for each timeframe int handle = FileOpen(fname, FILE_CSV|FILE_WRITE, ","); // "," means that output data will be separated by commas; change if necessary if (handle<0) return(0); FileWrite(handle,"Date,Time,Open,Low,High,Close,Volume,Upticks,Downticks"); // This writes the Header record to the file (change or remove to suit) //for (int i=0; i<iBars(ccy,tf); i++) // Use descending date sequence for (int i=iBars(ccy,tf)-1; i>=0; i--) { // Use ascending date sequence string date1 = TimeToStr(iTime(ccy,tf,i),TIME_DATE); date1 = StringSubstr(date1,5,2) + "-" + StringSubstr(date1,8,2) + "-" + StringSubstr(date1,0,4); // NOTE: StringSubstr(date1,5,2) is the MONTH // StringSubstr(date1,8,2) is the DAY // StringSubstr(date1,0,4) is the YEAR (4 digits) // "-" means the separator will be a hyphen // So if, for example, you want to change the output date format to DD/MM/YYYY, change the above line of code to: // date1 = StringSubstr(date1,8,2) + "/" + StringSubstr(date1,5,2) + "/" + StringSubstr(date1,0,4); string time1 = TimeToStr(iTime(ccy,tf,i),TIME_MINUTES); double sma12 = 0; for (int j=0; j<12; j++) sma12 += iMomentum(ccy,tf,25,PRICE_CLOSE,i+j)/12; FileWrite(handle, date1, time1, iOpen(ccy,tf,i), iLow(ccy,tf,i), iHigh(ccy,tf,i), iClose(ccy,tf,i), iVolume(ccy,tf,i), sma12); // The above line writes the data to the file in the order: date, time, open, low, high, close, volume. Change the order to suit, if necessary } FileClose(handle); Comment("History output complete"); // Display a comment in the upper left corner of the chart to advise that process is complete return(0); }