Artyom Trishkin #: A person wanted to show in an example how to copy three bars. You can copy as many bars as you need. But for the Expert Advisor, as well as usually, it is enough to know the current volatility. It is only one zero, the current bar.
Can you tell me if this is the correct way to normalise to 5 decimal places?
//+------------------------------------------------------------------+//| Export Indicator Values |//+------------------------------------------------------------------+#property description"This Script Export Indicators Values to CSV File."#property description"(You can change the iCustom function parameters to change what indicator to export)"#property copyright"NFTrader"#property version"2.00"#property script_show_inputsinputint IndicatorPeriod=14;
inputstring Indicator_Directory_And_Name="Examples\\RSI";
//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
MqlRates rates_array[];
string sSymbol=Symbol();
// Convert Period to string to use it in the file namestring sPeriod=EnumToString(Period());
// Comment to appear in the up left screenComment("Exporting ... Please wait... ");
// Prepare file name, e.g: EURUSD_PERIOD_H1(RSI,14)string ExtFileName; // ="XXXXXX_PERIOD_H1(RSI,14).CSV";
ExtFileName=sSymbol;
int pos=StringFind(Indicator_Directory_And_Name,"\\",0);
string indicatorName=StringSubstr(Indicator_Directory_And_Name,pos+1,-1);
string indicatorPeriod=IntegerToString(IndicatorPeriod);
StringConcatenate(ExtFileName,sSymbol,"_",sPeriod,"(",indicatorName,",",indicatorPeriod,")",".CSV");
ArraySetAsSeries(rates_array,true);
int MaxBar=TerminalInfoInteger(TERMINAL_MAXBARS);
int iCurrent=CopyRates(sSymbol,Period(),0,MaxBar,rates_array);
double IndicatorBuffer[];
SetIndexBuffer(0,IndicatorBuffer,INDICATOR_DATA);
int bars=Bars(sSymbol,PERIOD_CURRENT);
int to_copy=bars;
int rsiHandle=iCustom(sSymbol,PERIOD_CURRENT,Indicator_Directory_And_Name,IndicatorPeriod); // Change here.CopyBuffer(rsiHandle,0,0,to_copy,IndicatorBuffer);
ArraySetAsSeries(IndicatorBuffer,true);
int fileHandle=FileOpen(ExtFileName,FILE_WRITE|FILE_CSV);
for(int i=iCurrent-IndicatorPeriod-1; i>0; i--)
{
string outputData=StringFormat("%s",TimeToString(rates_array[i].time,TIME_DATE));
outputData+=","+TimeToString(rates_array[i].time,TIME_MINUTES);
outputData+=","+ DoubleToString(IndicatorBuffer[i],5);
outputData+="\n";
FileWriteString(fileHandle,outputData);
}
FileClose(fileHandle);
Comment("Exported Successfully");
}
//+------------------------------------------------------------------+
My EA isn't running on meta4 desktop even if i use the preinstalled EA expert that they have. I have selected the auto trade, allowed trading when changing accounts, it has a smiley face and in the bottom at experts it shows all is good. So why isn't it opening trades?
A person wanted to show in an example how to copy three bars. You can copy as many bars as you need. But for the Expert Advisor, as well as usually, it is enough to know the current volatility. It is only one zero, the current bar.
Good information. Thank you.
Can you tell me if this is the correct way to normalise to 5 decimal places?
Here in this place
I just get discrepancies with the real data.Is this the correct way to normalise to 5 decimal places ?
This iswhere
I get discrepancies with the real data.
And it is definitely necessary to do it this way? It is just not clear to me for what purpose you take away the period of the indicator:
Regards, Vladimir.
HI there.
My EA isn't running on meta4 desktop even if i use the preinstalled EA expert that they have. I have selected the auto trade, allowed trading when changing accounts, it has a smiley face and in the bottom at experts it shows all is good. So why isn't it opening trades?
Any Advise or Help??
Is it really necessary to do it this way? It is just not clear to me for what purpose you take away the period of the indicator:
I don't know how to do it myself)
Code from the codebase.
Hello.
What is the error when compiling ?
'operator[]' - constant variable cannot be passed as reference
how to fix ?
I don't know the right way myself)
Code from the codebase.
For the sake of interest, remove what I highlighted in yellow and see the result. It will be interesting to see what you get. ))
Regards, Vladimir.
For the sake of interest, remove what I highlighted in yellow and see the result. It will be interesting to see what you get. ))
There are no differences.
The data is the same
For the sake of interest, remove what I highlighted in yellow and see the result. It will be interesting to see what you get. ))
In your variant, the export of indicator values is 1 bar earlier.
Otherwise, there are no differences.
I don't know why the author did it.
But I have a problem with normalisation of exported data to 5 digits
Hello.
What is the compilation error ?
'operator[]' - constant variable cannot be passed as reference
how to fix ?
Maybe you should explicitly specify the wordconst?
Regards, Vladimir.