
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
I am looking for a solution to apply indicators algorithmics on array of prices.
in MQL4 some indicators has this function, such as: iCCIOnArray, iBandsOnArray...
But indicators such as ADX does not have such function.
Anyone have idea of how I may apply indicator calculation over pre-defined array (not from quotes server)?[lang=pl]If you know how given indicator is calutaded you can make everything:)
Please explain more precisly what excactly you need
Cheers,
Grzesiek[/lang]
...
ADX uses what is called atrue range(Max(High,PreviousClose)-Min(Low,PreviousClose) and that is the basis of ADX calculation
Because of High, Low and Close values required it can not be applied to an array, In general, if you see that there is a price required, then the indicator should be applicable to an array. If there is no price parameter, then almost sure it can not be applied to an array (assuming that the indicator in the first place is operating on prices)
[lang=pl]If you know how given indicator is calutaded you can make everything:)
Please explain more precisly what excactly you need
Cheers,
Grzesiek[/lang]Thank you Grzesiek.
I was searching for good solution. eventually, the best resolution, is to to embed the indi code into the expert code.
anyway, unless anyone show me other way, I will apply it this way.
Do you have source file? *.ex4 file is compiled, so You dont have Access to source code.
Regards
request
star821
Try this one out
________________________
Some explanations : I did not use the ones you posted but made these (indicator attached in your post has my name in it, but that version is not made by me, but that is not the only reason I did not use that indicator). ...
regards
Mladenhelo Mladen
is it posible to adapt the stc EA for a HMA color nrp-indi and High-low trend indi?...
i wrote a pseudo code (* can't code at all...
*):
************************************************************
externals:
Lot#
period for the HMA
???.
.....................
repeat:
get the zigzag-dot color (bar close);
get the HMA trend color (bar close);
----------------------------------------------------------------
// open sell
if last zigzag-dot = blue && HMA trend = red -> open SELL ticket (only once per HMA trend color)
if couldn't open sell-> retry 3 times
if no success alert & email: couldn't open sell for symbol,TF, time;
else
// open buy
if last zigzag-dot =red && HMA trend = blue -> open BUY ticket (only once per HMA trend color)
if couldn't open buy-> retry 3 times
if no success alert & email: couldn't open buy for symbol,TF, time;
-------------------------------------------------------------------
if HMA trend ( red ) changes to blue -> close sell, wait 10 sec. ;
if HMA trend ( blue ) changes to red -> close buy, wait 10 sec.;
-------------------------------------------------------------------
close all trades on friday at 12:00h AM (GMT)...
****************************************************************
i know that there will be some loses but it doesn't bother me...
i don't want any SLs ...
regards
Cado
hma_color_nrp.ex4high_-_low_trend.mq4
ATR + MA & Bandwidth + MA
[lang=it]Hi, I need a custom indicator that, in a separate window, write atr and moving average calculate on it and same thing for bandwidth. I have made the code in mql4 and I have using the IMAONARRAY for calculate the MA, but the indicator don' t work..can anyone help me???
This is one of teo codes..
Thanks
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int AtrPeriod=14;
//---- buffers
double AtrBuffer[];
double TempBuffer[];
double MaBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 1 additional buffer used for counting.
IndicatorBuffers(2);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,AtrBuffer);
SetIndexBuffer(1,TempBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,MaBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="ATR("+AtrPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,AtrPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Average True Range |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=AtrPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=AtrPeriod;i++) AtrBuffer=0.0;
//----
i=Bars-counted_bars-1;
while(i>=0)
{
double high=High;
double low =Low;
if(i==Bars-1) TempBuffer=high-low;
else
{
double prevclose=Close;
TempBuffer=MathMax(high,prevclose)-MathMin(low,prevclose);
}
i--;
}
//----
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(i=0; i<limit; i++)
AtrBuffer=iMAOnArray(TempBuffer,Bars,AtrPeriod,0,MODE_SMA,i);
//----
double MyArray[];
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
ArrayResize( MyArray, limit);
ArraySetAsSeries(MyArray,true);
for(i=0; i<limit; i++)
{
MyArray = AtrBuffer;
}
for(i=0; i<limit; i++)
{
MaBuffer = iMAOnArray(MyArray,limit,10,0,MODE_SMA,i);
}
//----
return(0);
}
//+------------------------------------------------------------------+[/lang]
...
Try it out now
[lang=it]Hi, I need a custom indicator that, in a separate window, write atr and moving average calculate on it and same thing for bandwidth. I have made the code in mql4 and I have using the IMAONARRAY for calculate the MA, but the indicator don' t work..can anyone help me???
This is one of teo codes..
Thanks
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int AtrPeriod=14;
//---- buffers
double AtrBuffer[];
double TempBuffer[];
double MaBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 1 additional buffer used for counting.
IndicatorBuffers(2);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,AtrBuffer);
SetIndexBuffer(1,TempBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,MaBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="ATR("+AtrPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,AtrPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Average True Range |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=AtrPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=AtrPeriod;i++) AtrBuffer=0.0;
//----
i=Bars-counted_bars-1;
while(i>=0)
{
double high=High;
double low =Low;
if(i==Bars-1) TempBuffer=high-low;
else
{
double prevclose=Close;
TempBuffer=MathMax(high,prevclose)-MathMin(low,prevclose);
}
i--;
}
//----
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(i=0; i<limit; i++)
AtrBuffer=iMAOnArray(TempBuffer,Bars,AtrPeriod,0,MODE_SMA,i);
//----
double MyArray[];
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
ArrayResize( MyArray, limit);
ArraySetAsSeries(MyArray,true);
for(i=0; i<limit; i++)
{
MyArray = AtrBuffer;
}
for(i=0; i<limit; i++)
{
MaBuffer = iMAOnArray(MyArray,limit,10,0,MODE_SMA,i);
}
//----
return(0);
}
//+------------------------------------------------------------------+[lang=tr]Hi Can Some one help me for to build this formula in metatrader code
(this is in metastock formula:)
Q1:=Input("PERIOD",1,1000,3);
Q2:=Input("PERIOD",0.001,100,1);
Q3:=Q2/100;
Q4:=Mov( Typical(),Q1,E) ;
Q5:=If((Q4*(1-Q3))>PREV,Q4*(1-Q3),If((Q4*(1+Q3))<PREV,Q4*(1+Q3),PREV));
Q5
...
Interesting one
The only thing you need to adjust for different time frames is the percent. 1% seems as a good choice for a 4 hour chart, but here is an example of a 15 minute chart with 0.5% instead of the default 1%
PS: I have no idea what the original name of it is, so named it as is
regards
mladen
[lang=tr]Hi Can Some one help me for to build this formula in metatrader code
(this is in metastock formula:)
Q1:=Input("PERIOD",1,1000,3);
Q2:=Input("PERIOD",0.001,100,1);
Q3:=Q2/100;
Q4:=Mov( Typical(),Q1,E) ;
Q5:=If((Q4*(1-Q3))>PREV,Q4*(1-Q3),If((Q4*(1+Q3))<PREV,Q4*(1+Q3),PREV));
Q5
Interesting one
The only thing you need to adjust for different time frames is the percent. 1% seems as a good choice for a 4 hour chart, but here is an example of a 15 minute chart with 0.5% instead of the default 1%
PS: I have no idea what the original name of it is, so named it as is
regards
mladen[lang=tr]thank you mladen i will try it , i think it will work
[/lang]