I'm guessing you have an array out of range error in your log? You do not SetIndexBuffer for A[].
I suspect you'll also have problems with your color assignment (indicator_color2 Red)
And possibly also your indicator minimum (indicator_minimum 0) .... natural log of values >0 && <1 are negative (think USDCHF, for example).
I'm guessing you have an array out of range error in your log? You do not SetIndexBuffer for A[].
I suspect you'll also have problems with your color assignment (indicator_color2 Red)
And possibly also your indicator minimum (indicator_minimum 0) .... natural log of values >0 && <1 are negative (think USDCHF, for example).
I modified the values in [-1,1] But I still get not the values of log.
#property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 2 #property indicator_color2 Red #property indicator_minimum -1 #property indicator_maximum 1 double A[]; double B[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexBuffer(0,B); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,indicator_color2); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if (counted_bars>0) counted_bars--; int limit= Bars-counted_bars; for (int i=0;i<limit;i++) { //---- A[i]=(High[i]); B[i]=MathLog(A[i]); } return(0); } //+------------------------------------------------------------------+
The problem is that you have declared an array A[] but it has no size.
So when you access A[i] it is going to be out of range. Have you checked your Experts Tab?
Why don't you dispense with A altogether:
#property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window //#property indicator_buffers 2 #property indicator_buffers 1 //#property indicator_color2 Red #property indicator_color1 Red //#property indicator_minimum -1 //#property indicator_maximum 1 double A[]; //double B[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators // SetIndexBuffer(0,B); // SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,indicator_color2); SetIndexBuffer(0,A); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if (counted_bars>0) counted_bars--; int limit= Bars-counted_bars; for (int i=0;i<limit;i++) { //---- // A[i]=(High[i]); // B[i]=MathLog(A[i]); A[i]=MathLog(High[i]); } return(0); } //+------------------------------------------------------------------+
The problem is that you have declared an array A[] but it has no size.
So when you access A[i] it is going to be out of range. Have you checked your Experts Tab?
Why don't you dispense with A altogether:
As you have done in the corrected code with //B's related commenting ?
The problem is that you have declared an array A[] but it has no size.
So when you access A[i] it is going to be out of range. Have you checked your Experts Tab?
Why don't you dispense with A altogether:
I have understood that 15, but with this instruction, I do not get more than 8:
int init() { //---- indicators // SetIndexBuffer(0,A); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); IndicatorDigits(Digits+10); return(0); }
I believe you meant dispense with B altogether right ?
As you have done in the corrected code with //B's related commenting ?
Dispense with either because only 1 is necessary.
But you are quite right though, because of my code I should have written B not A.
I have understood that 15, but with this instruction, I do not get more than 8:
The values of A are stored as doubles, so their representation accuracy is 15 significant digits. You can see this by printing the values of A.
int start() { int counted_bars=IndicatorCounted(); if (counted_bars>0) counted_bars--; int limit= Bars-counted_bars; for (int i=0;i<limit;i++) { //---- // A[i]=(High[i]); // B[i]=MathLog(A[i]); A[i]=MathLog(High[i]); printf("%.15f",A[i]); } return(0); }
However, I'm not sure how many digits the data window is capable of showing.
The values of A are stored as doubles, so their representation accuracy is 15 significant digits. You can see this by printing the values of A.
However, I'm not sure how many digits the data window is capable of showing.
If it is a question I had about the decimals it supports. Still, I do not show me more than 8 decimal places, and I instuccion the previous post:
int init() { //---- indicators // SetIndexBuffer(0,A); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); IndicatorDigits(Digits+10); return(0); } int start() { int counted_bars=IndicatorCounted(); if (counted_bars>0) counted_bars--; int limit= Bars-counted_bars; for (int i=0;i<limit;i++) { //---- // A[i]=(High[i]); // B[i]=MathLog(A[i]); A[i]=MathLog(High[i]); printf("%.15f",A[i]); } return(0); }
Take a look at NormalizeDouble - it might be what you are after.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Why in the following code, does not draw logarithms?
Thank You very much