There are so much problems in such a little code. You need to learn, see this to start.
What you should know about indicators
- www.mql5.com
The next article is Applying One Indicator to Another.
Alain Verleyen:
There are so much problems in such a little code. You need to learn, see this to start.
There are so much problems in such a little code. You need to learn, see this to start.
Tq..I already add buffer..
But how to get Higher high in previous 10 data? Help me.. my loop problem..
Files:
310-indi.mq5
3 kb
uyin:
You don't need CopyHigh/CopyLow as you already have all history available as OnCalculate() parameters.Tq..I already add buffer..
But how to get Higher high in previous 10 data? Help me.. my loop problem..
ArrayMaximum/ArrayMinimum is the correct way (though not the fastest solution to apply it on each candle, but forget that for now). However you have to pay attention to the indexing, in MT5 arrays/buffers are not indexed as series by default (see ArraySetAseries()). Also these functions returns an index not the maximum itself.
int highest = ArrayMaximum (high,i,10);
HH[i]=high[highest];
HH[i]=high[highest];
Skip the round in this line too :
Range[i] = round((HH[i]-LL[i])/3);
Your range will result in 0 almost all the time
Ty all..I almost finish..but only fail at line:
CL[bar]= close[ArrayMinimum(close,bar-i,10)];
"Error : Array Out of Range"
Why this happen?
CL[bar]= close[ArrayMinimum(close,bar-i,10)];
"Error : Array Out of Range"
Why this happen?
Files:
310_3.mq5
3 kb
uyin:
Ty all..I almost finish..but only fail at line:
CL[bar]= close[ArrayMinimum(close,bar-i,10)];
"Error : Array Out of Range"
Why this happen?
Wrong parameters and your ArrayMinimum() returns -1 as a result. Check the parameters for the function call
Ty all..I almost finish..but only fail at line:
CL[bar]= close[ArrayMinimum(close,bar-i,10)];
"Error : Array Out of Range"
Why this happen?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
Newbie here.
I want to make simple indicator but error. I'm stuck. Actually this is my first indi to make.
Formula :
Indicator Signal = ((Highest Hi previous 10 period - Lowest Low previous 10 period) / 3) + Lowest Low previous 10 period
Anyone can help me?
------------- edited by moderator to include SRC -------------
//| 310-indi.mq5 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//--- plot Signal
#property indicator_label1 "Signal"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- indicator buffers
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,SignalBuffer,INDICATOR_DATA);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
double HH[], LL[], Range [];
ArraySetAsSeries(HH,true);
ArraySetAsSeries(LL,true);
ArraySetAsSeries(Range,true);
int i;
for(i=prev_calculated;i<rates_total;i++)
{
HH[i] = ArrayMaximum (high,0,11);
LL[i] = ArrayMinimum (low,0,11);
Range[i] = round((HH[i]-LL[i])/3);
double newLL = LL[i]+Range[i];
SignalBuffer[i] = newLL;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+