Coding help - page 288

Mladen Rakic
186916
Mladen Rakic  
12BPRO:
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)

[Deleted]  

Hi,

Firstly an apology if this is in the wrong place, its a pivot indi i am looking at but my Q is in relation to coding, I could have put it in MTF as well but I thought this was best place to start.

In MT4 we have daily, weekly, monthly = W1, D1, MN1

but is there a year function, or a quarter function.

So for example in the attached pivot indicator how do you get 1 year, and is it (or can you choose) a rolling 12 months or a fixed prev year 2013 example. And same for how do I get it to calculate quarterly pivots.

Any guidance would be appreciated, attached is a monthly pivot indi. i am reasonably confident I can modify the attached but I do not know how to start to get the data into it to make it output quarters or year.

allpivots_monthly.mq4

Many thanks

Kevin

Files:
AZRUL FYZEE AZMI
213
AZRUL FYZEE AZMI  
mladen:
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)

Dear Sir MLADEN...

Could you replace this (#pollan indy) with any other indicator that you have... may be call #VQ bars.... PLEASE give it a try.... cause I do have a reading on the indicator buffer as attached picture... but I couldn't call via iCustom in my EA to further test this '#pollan indy"...

Hope to here from you again soon... THANKS

Yours truly

AZRUL

Files:
my_vq.jpg 48 kb
Mladen Rakic
186916
Mladen Rakic  
12BPRO:
Dear Sir MLADEN...

Could you replace this (#pollan indy) with any other indicator that you have... may be call #VQ bars.... PLEASE give it a try.... cause I do have a reading on the indicator buffer as attached picture... but I couldn't call via iCustom in my EA to further test this '#pollan indy"...

Hope to here from you again soon... THANKS

Yours truly

AZRUL

There is no need to replace #VQ with #VQ (it is already calculating volatility quality)

If it works as it should with the regular #VQ the only logical conclusion is that there is something wrong with "#pollan indy"

Hermo
383
Hermo  

Coding help

Good morning to all

Hello mladen

I am trying to create my first codes.

Learn from other codes, since there is no manual MT4 in my language.

I pray not laugh at my code.

Please can help me it works.

It is a simple indicator that marks the creation of a Doji.

I beg your help.

Thank you very much in advance.

Best regards.

Hermo.

PD. Compiles fine but does not work.

Files:
Mladen Rakic
186916
Mladen Rakic  
Hermo:
Good morning to all

Hello mladen

I am trying to create my first codes.

Learn from other codes, since there is no manual MT4 in my language.

I pray not laugh at my code.

Please can help me it works.

It is a simple indicator that marks the creation of a Doji.

I beg your help.

Thank you very much in advance.

Best regards.

Hermo.

PD. Compiles fine but does not work.

Hermo

Will check it

Waiting ECB press conference now :):)

AZRUL FYZEE AZMI
213
AZRUL FYZEE AZMI  
mladen:
There is no need to replace #VQ with #VQ (it is already calculating volatility quality) If it works as it should with the regular #VQ the only logical conclusion is that there is something wrong with "#pollan indy"

Dear Sir MLADEN...

That is why in the first place I didn't post my #VQ.... may be you are right about there is something wrong about the "pollan indy" and YES it repaint....

For me, I just would like to try my theory, with this indicator just to see what's the outcome....

The thing is that I couldn't call the indicator buffer in my EA... may be it is caused by the modified version of my #VQ that is blocking the iCustom call to my EA....

With the original #VQ it works just fine... and I could run my EA.... but with the modified #VQ (mine), I couldn't excess but still there is a value as shown in the previous thread..

I think the problem is with my MODIFIED #VQ version.... may be some syntax error... PLEASE if you have time take a look and see if it is working as it should..... just for the LEARNING PURPOSES....

THANKS... I HAVE GOT THAT EA RUNNING NOW AND TESTING IF YOU ARE INTERESTED IN FINDING OUT THE OUTCOME I WILL POST IT IN THE POLLAN THREAD.....

yours truly..

AZRUL

Mladen Rakic
186916
Mladen Rakic  
12BPRO:
Dear Sir MLADEN...

That is why in the first place I didn't post my #VQ.... may be you are right about there is something wrong about the "pollan indy" and YES it repaint....

For me, I just would like to try my theory, with this indicator just to see what's the outcome....

The thing is that I couldn't call the indicator buffer in my EA... may be it is caused by the modified version of my #VQ that is blocking the iCustom call to my EA....

With the original #VQ it works just fine... and I could run my EA.... but with the modified #VQ (mine), I couldn't excess but still there is a value as shown in the previous thread..

I think the problem is with my MODIFIED #VQ version.... may be so syntax error... PLEASE if you have time take a look and see if it is working as it should.....

THANKS... and sorry for any negative input.....

yours truly..

AZRUL

AZRUL

I simply can not know what is happening with your "pollan indy" without seeing the code

All I can do is guess, and guessing in coding is very, very bad

all the best

AZRUL FYZEE AZMI
213
AZRUL FYZEE AZMI  
mladen:
AZRUL

I simply can not know what is happening with your "pollan indy" without seeing the code

All I can do is guess, and guessing in coding is very, very bad

all the best

I HAVE GOT THAT EA RUNNING NOW AND TESTING IF YOU ARE INTERESTED IN FINDING OUT THE OUTCOME I WILL POST IT IN THE POLLAN THREAD.....

IT WAS MY VERSION OF THE #VQ THAT DIDN'T WORK...

THANKS...

yours truly..

AZRUL

AZRUL FYZEE AZMI
213
AZRUL FYZEE AZMI  

Hi CODESGURUS,

I have a general question about multi time frame.... as attached

the first picture on the left hand side is a RSI indicator on a 5M timeframe...

On the second is the RSI multi time frame of the 5M on the 15M timeframe...

The question is why is there a difference in the value as indicated in the RED circle....

Can someone PLEASE explain and rectify this RsiMA-MTF codes........

#property indicator_separate_window

#property indicator_buffers 6

#property indicator_color1 Lime

#property indicator_color2 Red

#property indicator_color3 Aqua

#property indicator_color4 Yellow

#property indicator_color5 White

#property indicator_color6 Magenta

#property indicator_width1 1

#property indicator_width2 1

#property indicator_width3 1

#property indicator_width4 1

#property indicator_width5 1

#property indicator_width6 1

//-------------------------------------

//-----

//extern string TimeFrames = "M15; M60";

extern bool TimeFrame1bool = true;

extern int TimeFrame1 = 0;

extern bool TimeFrame2bool = False;

extern int TimeFrame2 = 0;

extern bool TimeFrame3bool = False;

extern int TimeFrame3 = 0;

//int period[]={1,5,15,30,60,240,1440,43200};

//string periodString[]={"M1","M5","M15","M30","H1","H4","D1",MN1"};

// create one more array with indicator names

//string signalNameString[]={"MA"};

int ExtCountedBars=0;

//---------------------

int TF;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];

double ExtMapBuffer5[];

double ExtMapBuffer6[];

//-------

//+------------------------------------------------------------------+

int init()

{

SetIndexBuffer(0, ExtMapBuffer1);

SetIndexBuffer(1, ExtMapBuffer2);

SetIndexBuffer(2, ExtMapBuffer3);

SetIndexBuffer(3, ExtMapBuffer4);

SetIndexBuffer(4, ExtMapBuffer5);

SetIndexBuffer(5, ExtMapBuffer6);

//-----

SetIndexStyle(0, DRAW_LINE);

SetIndexStyle(1, DRAW_LINE);

SetIndexStyle(2, DRAW_LINE);

SetIndexStyle(3, DRAW_LINE);

SetIndexStyle(4, DRAW_LINE);

SetIndexStyle(5, DRAW_LINE);

// SetIndexStyle(0,DRAW_LINE,EMPTY,1);

// SetIndexBuffer(0,ExtMapBuffer1);

//-------------------------------------------------------------+++

int M1 = PERIOD_M1;

int M5 = PERIOD_M5;

int M15 = PERIOD_M15;

int M30 = PERIOD_M30;

int H1 = PERIOD_H1;

int H4 = PERIOD_H4;

int D1 = PERIOD_D1;

int WK1 = PERIOD_W1;

int MN1 = PERIOD_M1;

TF=Period();

if (TF==PERIOD_M1) { TimeFrame1 = M1; TimeFrame2 = M1; TimeFrame3 = M1;}

else if (TF==PERIOD_M5) { TimeFrame1 = M1; TimeFrame2 = M5; TimeFrame3 = M15;}

else if (TF==PERIOD_M15) { TimeFrame1 = M5; TimeFrame2 = M15; TimeFrame3 = H1; }

else if (TF==PERIOD_M30) { TimeFrame1 = M5; TimeFrame2 = M15; TimeFrame3 = H1; }

else if (TF==PERIOD_H1) { TimeFrame1 = M15; TimeFrame2 = H1; TimeFrame3 = H4; }

else if (TF==PERIOD_H4) { TimeFrame1 = H4; TimeFrame2 = H4; TimeFrame3 = D1; }

else if (TF==PERIOD_D1) { TimeFrame1 = H4; TimeFrame2 = D1; TimeFrame3 = WK1;}

else if (TF==PERIOD_W1) { TimeFrame1 = D1; TimeFrame2 = WK1; TimeFrame3 = MN1;}

else if (TF==PERIOD_MN1) { TimeFrame1 = D1; TimeFrame2 = WK1; TimeFrame3 = MN1;}

else { TimeFrame1 = D1; TimeFrame2 = WK1; TimeFrame3 = MN1;}

//-----

return(0);

}

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray1[];

datetime TimeArray2[];

datetime TimeArray3[];

int limit, i,y=0;

// int counted_bars = IndicatorCounted();

ExtCountedBars=IndicatorCounted();

if(ExtCountedBars < 0) return(-1);

if(ExtCountedBars > 0) ExtCountedBars--;

limit = Bars - ExtCountedBars;

//-----

ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame1);

ArrayCopySeries(TimeArray2,MODE_TIME,Symbol(),TimeFrame2);

ArrayCopySeries(TimeArray3,MODE_TIME,Symbol(),TimeFrame3);

for(i=0,y=0;i<limit;i++)

{

if(TimeFrame1bool)

{

if (Time<TimeArray1[y]) y++;

{

//ExtMapBuffer1

ExtMapBuffer1 = iCustom(NULL,TimeFrame1 , "#RSI-MA",0, y);

ExtMapBuffer2 = iCustom(NULL,TimeFrame1 , "#RSI-MA",3, y);

}

}

//-----

if(TimeFrame2bool)

{

if (Time<TimeArray2[y]) y++;

{

//ExtMapBuffer1

ExtMapBuffer3 = iCustom(NULL,TimeFrame2 , "#RSI-MA",0,y);

ExtMapBuffer4 = iCustom(NULL,TimeFrame2 , "#RSI-MA",3,y);

}

}

//-----

if(TimeFrame3bool)

{

if (Time<TimeArray3[y]) y++;

{

//ExtMapBuffer1

ExtMapBuffer5 = iCustom(NULL,TimeFrame3 , "#RSI-MA",0, y);

ExtMapBuffer6 = iCustom(NULL,TimeFrame3 , "#RSI-MA",3, y);

}

}

}

//-----//--------------------------------------------------------------------------+

//=======================================================

return(0);

}

//+--------------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

Files: