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
Hello, I'm trying to extract the highest and lowest value for x periods of the main line of a stochastic in a buffer. I've read somewhere I need to make an Array with the values, but it doesn't work. So far I'm stuck with this code. Am I doing right, can someone help me with this ? Thanks a lot. Regards.
double num_array[1]={iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,CustomPeriod)};
int gmax=ArrayMaximum(num_array[1],WHOLE_ARRAY,0);
int gmin=ArrayMinimum(num_array[1],WHOLE_ARRAY,0);
MinBuffer=gmin;
MaxBuffer=gmax;
It's ok, I found the answer... Buffering the iStochastic, setting the values in a serie with ArraySetAsSeries, then do ArrayMaximum of the serie .
It's ok, I found the answer... Buffering the iStochastic, setting the values in a serie with ArraySetAsSeries, then do ArrayMaximum of the serie .
replace
ArrayMaximum(num_array[1],WHOLE_ARRAY,0);
ArrayMinimum(num_array[1],WHOLE_ARRAY,0);
with
ArrayMaximum(num_array,WHOLE_ARRAY,0);
ArrayMinimum(num_array,WHOLE_ARRAY,0);
sorry my bad, have mixed them up while still using the crrect one already dojh! stupid metaquotes for changing everythiung
You are not the only one with that kind of experience.
This is anything but user friendly
Hello Coders & Crackers,
Need your expertise in modifying a ZigZag on Close Indicator (attached ).
I need a ZigZag on Open instead ( same base settings). Alert on new candle open would be a nice touch ( if possible ).
Much appreciated,thanks !
Hello Coders & Crackers,
Need your expertise in modifying a ZigZag on Close Indicator (attached ).
I need a ZigZag on Open instead ( same base settings). Alert on new candle open would be a nice touch ( if possible ).
Much appreciated,thanks !Hello Razo, this is the zigzag open.
Hi All Gurus,
I am having problem with iCustom with the following indicator as attached... #VQ bars.
Could someone PLEASE show me how to extract the value for the following buffer....DIR[]
I using the following code to extract the buffer... but doesn't return any value....
double dir=iCustom(NULL,PERIOD_M1,"#VQ bars",4,0);
Could someone please have a look into this matter...
Your help and assistants is highly appreciated.....
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern int Length = 5;
extern int Method = 3;
extern int Smoothing = 1;
extern int Filter = 5;
extern bool Steady = false;
double VQ[];
double SumVQ[];
double DIR[];
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,UpBuffer);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,DnBuffer);
SetIndexBuffer(2,SumVQ);
SetIndexBuffer(3,VQ);
SetIndexBuffer(4,DIR);
if (Length < 2) Length = 2;
if (Method < 0) Method = 0;
if (Method > 3) Method = 3;
if (Smoothing < 0) Smoothing = 0;
if (Filter < 0) Filter = 0;
string short_name = "VQ | "+ Length + " , " +
Method + " , " + Smoothing + " , " + Filter + " | ";
IndicatorShortName(short_name);
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
SetIndexEmptyValue(2, 0.0);
SetIndexEmptyValue(3, 0.0);
return(0);
}
//+------------------------------------------------------------------+
int start()
{
double MH = 0, ML = 0, MO = 0, MC = 0, MC1 = 0;
int i, j, limit, counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//----
if(counted_bars<1) i=Bars-Length-1;
else i=Bars-counted_bars;
if(counted_bars<1)
{
j=Bars-Length-1;
SumVQ[j + 1] = Close[j + 1];
}
while (i >= 0)
{
MH = iMA(NULL,0,Length,0,Method,PRICE_HIGH,i);
ML = iMA(NULL,0,Length,0,Method,PRICE_LOW,i);
MO = iMA(NULL,0,Length,0,Method,PRICE_OPEN,i);
MC = iMA(NULL,0,Length,0,Method,PRICE_CLOSE,i);
MC1 = iMA(NULL,0,Length,0,Method,PRICE_CLOSE,i+Smoothing);
if (Steady==true)
{
MC=iMA(NULL,0,Length,0,Method,PRICE_MEDIAN,i);
MC1=iMA(NULL,0,Length,0,Method,PRICE_MEDIAN,i+Smoothing);
}
if((MH - ML)>0)
VQ = MathAbs(((MC - MC1) / MathMax(MH - ML, MathMax(MH - MC1, MC1 - ML)) + (MC - MO) / (MH - ML)) * 0.5) * ((MC - MC1 + (MC - MO)) * 0.5);
SumVQ = SumVQ + VQ;
if (Filter > 0)
if (MathAbs(SumVQ - SumVQ) < Filter * Point)
SumVQ = SumVQ;
i--;
}
if(counted_bars<1)
limit=Bars-Length-1;
else limit=Bars-counted_bars;
for (i = limit-1; i >= 0; i--)
{
if (SumVQ > SumVQ) DIR = 1;
if (SumVQ < SumVQ) DIR = -1;
if (SumVQ== SumVQ) DIR = DIR;
if (DIR > 0)
{
UpBuffer = High;
DnBuffer = Low;
}
else
if (DIR < 0)
{
DnBuffer = High;
UpBuffer = Low;
}
}
return(0);
}
Hi All Gurus,
I am having problem with iCustom with the following indicator as attached... #VQ bars.
Could someone PLEASE show me how to extract the value for the following buffer....DIR[]
I using the following code to extract the buffer... but doesn't return any value....
double dir=iCustom(NULL,PERIOD_M1,"#VQ bars",4,0);
Could someone please have a look into this matter...
Your help and assistants is highly appreciated.....Everything seems to be OK
Attaching the #vq bars as well as a test indicator that uses those values and it is showing correct values
Everything seems to be OK Attaching the #vq bars as well as a test indicator that uses those values and it is showing correct values
Wow... Thanks Sir MLADEN....
The strangest thing had happen... that code doesn't work on my indicator... cannot open error log....
but I did test it on the #VQ bars and it works just fine....
Wasted a few hours on that....
What can I say.... Owe you one....SIR.... for clearing this thing up for me.....
This is my #VQ.....
It has the value but when I call the iCustom in the EA is has no value.... what can I say.... silly me....
Dear Sir MLADEN,
Could you PLEASE look into my #VQ.... indicator... I deleted a few lines that I don't use.... and added a few alerts....
My be that's the cause of the problem for not being able to CALL the buffer in the EA via iCustom....
Your HELP once again is highly appreciated.....
Yours truly
AZRUL.......
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern int Length = 5;
extern int Method = 3;
extern int Smoothing = 1;
extern double Filter = 0.5;
extern bool Steady = False;
extern string SoundGbp = "news.wav";
extern string SoundEur = "news.wav";
extern bool PopupAlert = true;
extern bool SendPushNotification = false;
extern bool SoundAlert = True;
int lastAlert=3;
double VQ[];
double SumVQ[];
double DIR[];
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,UpBuffer);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,DnBuffer);
SetIndexBuffer(2,SumVQ);
SetIndexBuffer(3,VQ);
SetIndexBuffer(4,DIR);
if (Length < 2) Length = 2;
if (Method < 0) Method = 0;
if (Method > 3) Method = 3;
if (Smoothing < 0) Smoothing = 0;
if (Filter < 0) Filter = 0;
string short_name = "VQ | "+ Length + " , " +
Method + " , " + Smoothing + " , " + Filter + " | ";
IndicatorShortName(short_name);
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
SetIndexEmptyValue(2, 0.0);
SetIndexEmptyValue(3, 0.0);
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int i, limit, counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//----
if(counted_bars<1) i=Bars-Length;
else i=Bars-counted_bars;
if(counted_bars<1)
while (i >= 0)
{
VQ = iCustom(NULL,0,"#pollan indy",0,i+1);
SumVQ= iCustom(NULL,0,"#pollan indy",1,i+1);
//if (Filter > 0)
//if (MathAbs(VQ - SumVQ) < Filter)
//VQ = SumVQ;
i--;
}
if(counted_bars<1)
limit=Bars-Length-1;
else limit=Bars-counted_bars;
for (i = limit-1; i >= 0; i--)
{
//if (VQ > SumVQ) DIR = 1;
if ((VQ+VQ) > (SumVQ+SumVQ))
DIR = 1;
if ((VQ+VQ) < (SumVQ+SumVQ))
DIR = -1;
if ((VQ+VQ) == (SumVQ+SumVQ))
DIR = DIR;
if (DIR > 0)
{
UpBuffer = High;
DnBuffer = Low;
}
else
if (DIR < 0)
{
DnBuffer = High;
UpBuffer = Low;
}
if ((DIR > 0) && (DIR > 0))
{
CheckForAlerts(OP_BUY);//ALERT BUY
}
if ((DIR < 0) && (DIR < 0))
{
CheckForAlerts(OP_SELL);//ALERT SELL
}
}
double vq1=iCustom(NULL,0,"#pollan indy",0,i+1);
double svq1=iCustom(NULL,0,"#pollan indy",1,i+1);
double vq2=iCustom(NULL,0,"#pollan indy",0,i+2);
double svq2=iCustom(NULL,0,"#pollan indy",1,i+2);
double vq3=iCustom(NULL,0,"#pollan indy",0,i+3);
double svq3=iCustom(NULL,0,"#pollan indy",1,i+3);
double dir1=DIR;
double dir2=DIR;
double dir3=DIR;
double vq0= (vq1 + vq2);
double svq0= (svq1 + svq2);
string VQ0_Teks=DoubleToStr(vq0,6);
string VQS0_Teks=DoubleToStr(svq0,6);
string VQ1_Teks=DoubleToStr(vq1,6);
string VQS1_Teks=DoubleToStr(svq1,6);
string VQ2_Teks=DoubleToStr(vq2,6);
string VQS2_Teks=DoubleToStr(svq2,6);
string VQ3_Teks=DoubleToStr(vq3,6);
string VQS3_Teks=DoubleToStr(svq3,6);
string dir1_Teks=DoubleToStr(dir1,6);
string dir2_Teks=DoubleToStr(dir2,6);
string dir3_Teks=DoubleToStr(dir3,6);
string h =
" Blue" + " " + VQ0_Teks+ " " + " Red" + " " + VQS0_Teks + "\n" +
" Blue" + " " + VQ1_Teks+ " " + " Red" + " " + VQS1_Teks + "\n" +
" Blue" + " " + VQ2_Teks+ " " + " Red" + " " + VQS2_Teks + "\n" +
" Blue" + " " + VQ3_Teks+ " " + " Red" + " " + VQS3_Teks + "\n" + "\n" +
" DIR1" + " " + dir1_Teks+" " + "DIR2" + " " + dir2_Teks + " " +"DIR3" + " " + dir3_Teks;
Comment(h);
return(0);
}
//--------------------------------------------------------------
void CheckForAlerts(int type)
{
//ALERTS:
static datetime lastAlertTime=0;
if (lastAlertTime != iTime(NULL,0,0)) {
if (type==OP_BUY && lastAlert!=2) { //BUY
doAlerts("Pollan BAR UP "+Symbol()+" (tf:"+Period()+")",SoundEur);
lastAlert=2;
lastAlertTime=iTime(NULL,0,0);
}
if (type==OP_SELL && lastAlert!=1) { //SELL
doAlerts("Pollan BAR DOWN "+Symbol()+" (tf:"+Period()+")",SoundGbp);
lastAlert=1;
lastAlertTime=iTime(NULL,0,0);
}
}//if (lastAlertTime != iTime(NULL,0,0) {
//end ALERTS
}
//--------------------------------------------------------------
void doAlerts(string sMsg,string SoundFile) {
if (PopupAlert) Alert(sMsg);
if(SoundAlert) PlaySound(SoundFile);
if(SendPushNotification) SendNotification(sMsg);
}
THANKS........
Dear Sir MLADEN,
Could you PLEASE look into my #VQ.... indicator... I deleted a few lines that I don't use.... and added a few alerts....
My be that's the cause of the problem for not being able to CALL the buffer in the EA via iCustom....
Your HELP once again is highly appreciated.....
Yours truly
AZRUL.......
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern int Length = 5;
extern int Method = 3;
extern int Smoothing = 1;
extern double Filter = 0.5;
extern bool Steady = False;
extern string SoundGbp = "news.wav";
extern string SoundEur = "news.wav";
extern bool PopupAlert = true;
extern bool SendPushNotification = false;
extern bool SoundAlert = True;
int lastAlert=3;
double VQ[];
double SumVQ[];
double DIR[];
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,UpBuffer);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,DnBuffer);
SetIndexBuffer(2,SumVQ);
SetIndexBuffer(3,VQ);
SetIndexBuffer(4,DIR);
if (Length < 2) Length = 2;
if (Method < 0) Method = 0;
if (Method > 3) Method = 3;
if (Smoothing < 0) Smoothing = 0;
if (Filter < 0) Filter = 0;
string short_name = "VQ | "+ Length + " , " +
Method + " , " + Smoothing + " , " + Filter + " | ";
IndicatorShortName(short_name);
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
SetIndexEmptyValue(2, 0.0);
SetIndexEmptyValue(3, 0.0);
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int i, limit, counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//----
if(counted_bars<1) i=Bars-Length;
else i=Bars-counted_bars;
if(counted_bars<1)
while (i >= 0)
{
VQ = iCustom(NULL,0,"#pollan indy",0,i+1);
SumVQ= iCustom(NULL,0,"#pollan indy",1,i+1);
//if (Filter > 0)
//if (MathAbs(VQ - SumVQ) < Filter)
//VQ = SumVQ;
i--;
}
if(counted_bars<1)
limit=Bars-Length-1;
else limit=Bars-counted_bars;
for (i = limit-1; i >= 0; i--)
{
//if (VQ > SumVQ) DIR = 1;
if ((VQ+VQ) > (SumVQ+SumVQ))
DIR = 1;
if ((VQ+VQ) < (SumVQ+SumVQ))
DIR = -1;
if ((VQ+VQ) == (SumVQ+SumVQ))
DIR = DIR;
if (DIR > 0)
{
UpBuffer = High;
DnBuffer = Low;
}
else
if (DIR < 0)
{
DnBuffer = High;
UpBuffer = Low;
}
if ((DIR > 0) && (DIR > 0))
{
CheckForAlerts(OP_BUY);//ALERT BUY
}
if ((DIR < 0) && (DIR < 0))
{
CheckForAlerts(OP_SELL);//ALERT SELL
}
}
double vq1=iCustom(NULL,0,"#pollan indy",0,i+1);
double svq1=iCustom(NULL,0,"#pollan indy",1,i+1);
double vq2=iCustom(NULL,0,"#pollan indy",0,i+2);
double svq2=iCustom(NULL,0,"#pollan indy",1,i+2);
double vq3=iCustom(NULL,0,"#pollan indy",0,i+3);
double svq3=iCustom(NULL,0,"#pollan indy",1,i+3);
double dir1=DIR;
double dir2=DIR;
double dir3=DIR;
double vq0= (vq1 + vq2);
double svq0= (svq1 + svq2);
string VQ0_Teks=DoubleToStr(vq0,6);
string VQS0_Teks=DoubleToStr(svq0,6);
string VQ1_Teks=DoubleToStr(vq1,6);
string VQS1_Teks=DoubleToStr(svq1,6);
string VQ2_Teks=DoubleToStr(vq2,6);
string VQS2_Teks=DoubleToStr(svq2,6);
string VQ3_Teks=DoubleToStr(vq3,6);
string VQS3_Teks=DoubleToStr(svq3,6);
string dir1_Teks=DoubleToStr(dir1,6);
string dir2_Teks=DoubleToStr(dir2,6);
string dir3_Teks=DoubleToStr(dir3,6);
string h =
" Blue" + " " + VQ0_Teks+ " " + " Red" + " " + VQS0_Teks + "\n" +
" Blue" + " " + VQ1_Teks+ " " + " Red" + " " + VQS1_Teks + "\n" +
" Blue" + " " + VQ2_Teks+ " " + " Red" + " " + VQS2_Teks + "\n" +
" Blue" + " " + VQ3_Teks+ " " + " Red" + " " + VQS3_Teks + "\n" + "\n" +
" DIR1" + " " + dir1_Teks+" " + "DIR2" + " " + dir2_Teks + " " +"DIR3" + " " + dir3_Teks;
Comment(h);
return(0);
}
//--------------------------------------------------------------
void CheckForAlerts(int type)
{
//ALERTS:
static datetime lastAlertTime=0;
if (lastAlertTime != iTime(NULL,0,0)) {
if (type==OP_BUY && lastAlert!=2) { //BUY
doAlerts("Pollan BAR UP "+Symbol()+" (tf:"+Period()+")",SoundEur);
lastAlert=2;
lastAlertTime=iTime(NULL,0,0);
}
if (type==OP_SELL && lastAlert!=1) { //SELL
doAlerts("Pollan BAR DOWN "+Symbol()+" (tf:"+Period()+")",SoundGbp);
lastAlert=1;
lastAlertTime=iTime(NULL,0,0);
}
}//if (lastAlertTime != iTime(NULL,0,0) {
//end ALERTS
}
//--------------------------------------------------------------
void doAlerts(string sMsg,string SoundFile) {
if (PopupAlert) Alert(sMsg);
if(SoundAlert) PlaySound(SoundFile);
if(SendPushNotification) SendNotification(sMsg);
}
THANKS........You changed it to use "#pollan indy"
I have no idea what that indicator does (if it is like the rest of "pollan" indicators then it repaints and that can cause your problems, but just doing the guessing game now)