Moving Average changing slope for all symbols Alert - could you help ? - page 2

 
8284:

pairs[12]={"EURUSD","GBPUSD","USDJPY","AUDUSD","USDCAD","USDCHF","EURGBP","EURAUD","EURCHF","EURJPY","GBPJPY","GBPCHF"}

for (int i =0;i<12;i++)

{

mypair+i=iMa(pairs[i],.........................); // this will cycle through all your pairs

}

I created a cycle "for" again using symbols[12], ma[12] . Logically it should work, but it don't work.

If I use a pair lets say "EURUSD" instead of pair[1] it works.

What could be a reason ?

 

You might want to review this:

for (i = 1; i==12; i++) //I want to scan all symbols

 
edas wrote >>

I created a cycle "for" again using symbols[12], ma[12] . Logically it should work, but it don't work.

If I use a pair lets say "EURUSD" instead of pair[1] it works.

What could be a reason ?

its pair[i] not pair[1]. Pair [ i ] makes use of the cycle iterating 12 times to include all pairs. I noticed also that you also have a couple of timeframes. You will have to declare an array for them as well.

possibly

int timeframes[4] ={5,15,30,60};

string pairs[12]= { }; // your 12 pairs

for (int i= 0;i<4;i++)

{

for (int j=0;i<12;i++)

double myprice = iclose(pairs[j],timeframes[i],0);

double myaverage =iMA(pairs[ j],timeframes[ i ],..............);

if (myprice>myaverage)

objectcreate("mypair"+j); // and so on

}

 

you should move this otside the start function and give the arrays the needed dimension

int limit, i, counter;
double tmp=0;
double MAnow[], MAprev[], MAprev2[];

//move it after the extern section
int limit, i, counter;
double tmp=0;
double MAnow[12], MAprev[12], MAprev2[12];

maybe this solves the problem with MAnow.

not logical, but compiler and interpreters may contain bugs...

 
8284:

its pair[i] not pair[1]. Pair [ i ] makes use of the cycle iterating 12 times to include all pairs. I noticed also that you also have a couple of timeframes. You will have to declare an array for them as well.

possibly

int timeframes[4] ={5,15,30,60};

string pairs[12]= { }; // your 12 pairs

for (int i= 0;i<4;i++)

{

for (int j=0;i<12;i++)

double myprice = iclose(pairs[j],timeframes[i],0);

double myaverage =iMA(pairs[ j],timeframes[ i ],..............);

if (myprice>myaverage)

objectcreate("mypair"+j); // and so on

}

i suggest

objectcreate("mypair"+" "+j+" "+i);

because it maybe possible that different timeframes give the same result and the older object will be overwritten

 
I didnt put the full code here because I have many things Im doing at once but there is a way to prevent the older object from being overwritten. see here ObjectSet(object_id1,OBJPROP_XDISTANCE,(i*20)+20); This way you can move the x location every 20 pixels ( using obj_label) How you do this depends on how you want the indicator to look
 

Thank you, whocares, meikel, 8284, phy


You really helped me and indicator now is working :)

I will send you indicator after Christmas.


Merry Chistmas,


Edward

 
edas wrote >>

Thank you, whocares, meikel, 8284, phy

You really helped me and indicator now is working :)

I will send you indicator after Christmas.

Merry Chistmas,

Edward

Glad to have been of help .

Merry Christmas !!

 
edas:

Hello,


I want to create indicator (scanner), which informs when Moving Average changes slope. Slope changing gives short term reversal signal.

It is very easy to create such indicator for one currency (attached to graph, lets say EURUSD 5 min). Attached here indicator did such job and alers when MA changes slope.

But my idea is to scan many symbols and different time frame (let's say 5 min,15 min, 30 min) to have possibility to enter market as soon as signal comes.

Could You help ?


Thanks in advance,

Edward


Hi Edward et al,

I want to calculate the 'Absolute' angle of several currency pairs simultaneously. In my search for a solution on here many correctly pointed out the difficulty in this as the slope changes with the (Auto)scaling of the charts. If I cannot find any other method, I can overcome this by locking the all the charts to a 1 to 1 ratio.

But I WOULD like to figure out how to do it without using any charts at all.

I’m also wanting to utilize Calculus in EAs as well.

So far everything I have encountered has been along these lines posted here.

If I am unable to find and accommodate my preferences and the methods posted here are the best I can get with MQL4, then that is what it will have to be what I use as well.

Thus I to want to thank everyone for their input.

Wishing all of you and yours Peace, Happiness and Contentment in these HolyDays when again we celebrate the cycles of the waxing of the Dark into waning and the return and the waxing of the Light once more.

(8 >) Live Long and Prosper (< 8)

Sincerest Regards,

Doug

 

Calculate and compare slope, not angle.

slope is a rate, in this case pips per bar.

Reason: