[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 376

 
-xlapex-:

Here I have applied the MathAbs function, Alert shows zero and zero, but I would like a modulus of difference and a bar index...

int start()
{
int mas1[30,2],mas2[30,2],mas3[30,2],ind_1;
{
for (int i=1;i<=count_bars;i++)
{
mas1[i, 0]=Close[i];
mas1[i, 1]=i;
mas2[i, 0]=Open[ i];
mas2[i, 1]=i;

mas3[i, 0] = MathAbs(Close[ i]-Open[ i]);
mas3[i, 0] = i;

ArraySort( mas3);
mod_1=mas3[2, 0];
ind_1=mas3[2, 1];

Alert( mod_1," ",ind_1);
}
}

return(0);
}

Your arrays are int, and Open and Close are double correspondingly 1 - 1 = 0
 

Hi All

I am new to mql4 trying to write an Expert Advisor using the aligator indicator

I'm trying to write an EA on mql4 but nothing useful has come out yet.

Citizens Professionals may have asked you such trivial requests, questions , etc., but still could ask the professionals to write an expert on the aligator indicator

But still can ask you professionals to write an expert on the aligator indicator


Pips strategy


Buy and Sell positions are closed when StopLoss and TakeProfit are achieved

A buy signal when the green line crosses the blue and red from below upwards opens a Buy position

a Sell signal when green ruler crosses red and blue from upside down to open a Sell position

do not open more than one order until the crossover is closed


StopLoss =10;

TakeProfit =10;

Magic =33;

SlipPage =5;

Lot =0.1;

Thank you in advance


 
artmedia70:
Your arrays are int, but Open and Close are double
Replaced, still zeros. And another thing - in my two-dimensional arrays, one set is of double type, while the second one is of int type (bar indexes). How to bring them to one type while calculations, but to return to the former type again when the result is output?
 
-xlapex-:
Replaced, still zeros. One more thing - in my two-dimensional arrays, one set is of double type, and the second one is of int type (bar indexes). How to convert them to the same type for the time of calculations, but to return to the same type again when the result is output?

And what does count_bars equal?
 
Roger:

And what does count_bars equal?

count_bars = 30;


I've been thinking, and decided that two arrays are redundant, they are already programmatically specified. Now it will be easier to think. How can I reduce them to one type?

int start()
{
double mas1[30,2],mod_1;
int ind_1;
{
for (int i=1;i<=30;i++)
{
mas1[i, 0] = MathAbs(Close[i]-Open[i]);
mas1[i, 1] = i;

ArraySort(mas1);
mod_1=mas1[2, 0];
ind_1=mas1[2, 1];

Alert(mod_1," ",ind_1);
}
}
return(0);
}


 
-xlapex-:

count_bars = 30;

Then replace with

mod_1=mas1[2, 0];
ind_1=mas1[2, 1];

to

mod_1=mas1[i, 0];
ind_1=mas1[i, 1];
 
Roger:

Then replace with

to

Replaced. mod_1 gives set={1,3,5,7,9,...,29} and ind_1 keeps showing zero.
 
-xlapex-:
I replaced it. mod_1 gives set={1,3,5,7,9,...,29}, but ind_1 keeps showing zero.


does not show zero

double mas1[30,2],mod_1; 
int ind_1; 
for (int i=1;i<=30;i++)
{ 
   mas1[i, 0] = MathAbs(Close[i]-Open[i]);
   mas1[i, 1] = i;

   ArraySort(mas1);
   mod_1=mas1[i, 0];
   ind_1=mas1[i, 1];

   Print(mod_1," ",ind_1);
}

but your code is a bit incomprehensible

for example, the mas array hasn't been formed yet, but you are already sorting it

Maybe the context of your question makes it better:

double mas1[30,2],mod_1; 
int ind_1; 
for (int i=1;i<=30;i++)
{ 
   mas1[i, 0] = MathAbs(Close[i]-Open[i]);
   mas1[i, 1] = i;
}
ArraySort(mas1);
mod_1=mas1[2, 0];
ind_1=mas1[2, 1];
Print(mod_1," ",ind_1);
 
-xlapex-:
Replaced. mod_1 gives set={1,3,5,7,9,...,29}, but ind_1 keeps showing zero.

Yeah.... And why am I so absent-minded?!

It turns out that everything is simple - ArraySort(mas1,30,1,MODE_DESCEND ). All you have to do is write everything you're supposed to.

 
abolk:


does not show zero

but your code is a bit incomprehensible

for example, the mas array hasn't been generated yet and you're already sorting it

And what do you mean by "not formed". What else am I missing?
Reason: