Requests & Ideas - page 69

 
mikono:
Hi,

I have searched a script that can export indicator's value to a .csv file but none have the following options:

- number of bars to export; for example 2000 bars back from current time

- option to select which indicators to export (standard or custom indicator) and which value to export (an indicator may have several values)

- multiple time frame feature; for example if the script attached to M15 chart it calculates indicator value from H1. Therefore four bars in M15 chart will have the same indicator value derived from H1 timeframe

Currently I export indicators from Neuroshell Day Trader but I realize there are many interesting custom indicators for MT4 that can be used as neural inputs. I really appreciate if great coders here can make the above script.

Cheers

I think the simplest method to export standard & custom indicator is like this:

- first I open a chart, then I attach as many indicators that I want to export in that chart (standard and custom indicators)

- the script is thus attached to the chart and automatically detect all indicators and export its values to a .csv file

But I dont know the complexity of such method, because I really am not a coder . But thank you so much if it can be done

 
mikono:
Hi,

I have searched a script that can export indicator's value to a .csv file but none have the following options:

- number of bars to export; for example 2000 bars back from current time

- option to select which indicators to export (standard or custom indicator) and which value to export (an indicator may have several values)

- multiple time frame feature; for example if the script attached to M15 chart it calculates indicator value from H1. Therefore four bars in M15 chart will have the same indicator value derived from H1 timeframe

Currently I export indicators from Neuroshell Day Trader but I realize there are many interesting custom indicators for MT4 that can be used as neural inputs. I really appreciate if great coders here can make the above script.

Cheers

Have this indicator that exports data from metatrader to csv file in your experts/files folder, the -1 version has a ma coded into it to give you an idea how to code whichever indicator you want to use and also which format you want it in.In the rar file is an example of the values it gives out.

Files:
 
mrtools:
Have this indicator that exports data from metatrader to csv file in your experts/files folder, the -1 version has a ma coded into it to give you an idea how to code whichever indicator you want to use and also which format you want it in.In the rar file is an example of the values it gives out.

Thanks a lot mrtools

So if I want to add custom indicator, I just add one line code here:

if (dtval ThruDateTime) continue;

string dt = DateToStr(dtval,DateTimeFmt);

string open = NumberToStr(iOpen(CurrencyPair,TF,k),OHLCFmt);

string high = NumberToStr(iHigh(CurrencyPair,TF,k),OHLCFmt);

string low = NumberToStr(iLow(CurrencyPair,TF,k),OHLCFmt);

string close = NumberToStr(iClose(CurrencyPair,TF,k),OHLCFmt);

string vol = NumberToStr(iVolume(CurrencyPair,TF,k),VolFmt);

string SMA20 = NumberToStr(iMA(CurrencyPair,TF,20,0,MODE_SMA,PRICE_OPEN,k),OHLCFmt);

[/code]

And add additional variable here:

[code]

FileWrite(handle, dt, open, high, low, close, vol, SMA20);

Is that correct?

Sorry for my inability to read codes . Can you fix time format and include column name in csv file output? Here I attached example that I generate from NSDT.

Cheers

Files:
eurusd.zip  178 kb
 

No Help on my end?

 
mikono:
Thanks a lot mrtools

So if I want to add custom indicator, I just add one line code here:

if (dtval ThruDateTime) continue;

string dt = DateToStr(dtval,DateTimeFmt);

string open = NumberToStr(iOpen(CurrencyPair,TF,k),OHLCFmt);

string high = NumberToStr(iHigh(CurrencyPair,TF,k),OHLCFmt);

string low = NumberToStr(iLow(CurrencyPair,TF,k),OHLCFmt);

string close = NumberToStr(iClose(CurrencyPair,TF,k),OHLCFmt);

string vol = NumberToStr(iVolume(CurrencyPair,TF,k),VolFmt);

string SMA20 = NumberToStr(iMA(CurrencyPair,TF,20,0,MODE_SMA,PRICE_OPEN,k),OHLCFmt);

[/code]

And add additional variable here:

[code]

FileWrite(handle, dt, open, high, low, close, vol, SMA20);

Is that correct?

Sorry for my inability to read codes . Can you fix time format and include column name in csv file output? Here I attached example that I generate from NSDT.

Cheers

Exactly right, you can use any indicator, for time format you can change here

extern string DateTimeFmt = "M-D-Y,H:I"; if i remember right think nuero shell is YYYY.MM.DD enter it this way and should work in nuero shell, give me awhile to become familar with this indicatror, and hopefully will include column name.

 
mrtools:
Exactly right, you can use any indicator, for time format you can change here extern string DateTimeFmt = "M-D-Y,H:I"; if i remember right think nuero shell is YYYY.MM.DD enter it this way and should work in nuero shell, give me awhile to become familar with this indicatror, and hopefully will include column name.

It works, excellent Never mind about column name. I can entered it manually, so don't bother writing additional codes.

But I have a little problem. Your indicator put the newest data at the first row and the oldest at the last row; whereas neuroshell needs it the other way around: oldest data at the first row and newest data at the last row

 

Here is the one that does that

Some explanation of options :
regarding high lows :
HighLowPeriod- the period (number of bars) to seek for highs and lows

HighLowStartBar- the first bar to take into account when looking for highs and lows (by default it is set to 1, the first closed bar)

HighLowTimeFrame- time frame to check for highs and lows

general :
TrailAllSymbols- should it trail all the symbols or just the one from the current chart

TrailOnlyInProfit- set trailing stops only when order is already in profit or not

CloseWhenProfit- close orders when specific profit is reached (if 0, it will just manage trailing stops) It is a kind of a hidden take profit (profit specified is in currency, not pips)

magicNumber.from and magicNumber.to - to keep trailing stops only on orders belonging to specified range of magic numbers

showMessages- should it show messages of what is it doing to any of the orders

harsh124:
No Help on my end?
 
mikono:
It works, excellent Never mind about column name. I can entered it manually, so don't bother writing additional codes. But I have a little problem. Your indicator put the newest data at the first row and the oldest at the last row; whereas neuroshell needs it the other way around: oldest data at the first row and newest data at the last row

This version i found will add your header and will export your data either in ascending order or descending here's a description of external parameter

Load the attached indicator into your ...../experts/indicators folder and restart MT4.

Attach it to any MT4 chart, and enter your desired parameter settings. The export file gets re-created every time a new candle appears on your chart, and/or whenever you refresh the indicator. So if you want an updated export every minute, attach it to an M1 chart. If the export is to be once-only, then attach it to a longer timeframe chart, and remember to remove the indicator from the chart, before the next candle appears.

If you want to subtract 10 years from the date being exported, load into MT4 editor, un-comment the line of code that reads:

// dt = StrToTime((TimeYear(dt) - 10) + StringSubstr(TimeToStr(dt),4)); // subtracts 10 years from dt

and recompile.

Parameters work as follows:

Currency Pair: enter the symbol. Upper/lowercase doesn't matter. You can use shorthand if you wish, e.g. GU or gu for GBPUSD. If you leave blank, the data exported will from the pair whose chart you attached the indicator to

TimeFrame: enter the timeframe as one of M1, M5, M15, M30, H1, H4, D1, W1, MN. Upper/lowercase doesn't matter. If you leave blank, the data exported will from the chart timeframe you attached the indicator to

FromDateTime, ThruDateTime: candles timestamped outside this range will be excluded from the export

NumBars: only the last X candles' data will be exported. To obtain only the latest quote, set NumBars = 1

AscDesc: enter A or D. A = data export in ascending chronological sequence, i.e. earliest date/time at top of file. D = descending sequence, i.e. most recent date/time at top of file

Separator: the character used to separate the items being output

DateTimeFmt: the output format for the date/time. If you want the date and time as two separate output fields, include a Separator character in the appropriate place, in the field

OHLCFmt: the output format for the open, high, low and close values

VolFmt: the output format for the volume value

OutputFile: the name of your output file. Leave blank and it will default to ,.csv. The file will always be created in the ....../experts/files folder

Comments: if true, the comments "Export beginning....." and "Export completed....." will appear at the top left of the screen

So for nuero shell in your external parameters extern string AscDesc = "D"; if you change this to A you will get oldest data first.Also the yyyy.mm.dd should be the same.

Files:
 
mrtools:
This version i found will add your header and will export your data either in ascending order or descending here's a description of external parameter

Great

Thank you soooo much mrtools!

 

Mladen,

Can you smooth albRSI with interpolation(like your mtf interpolation) as a sample code.I would like to compare it with ma smoothing.Many thanks.

Files:
Reason: