[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

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
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 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);
}
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
Your arrays are int, but Open and Close are double
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?
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?
{
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);
}
count_bars = 30;
Then replace with
to
Then replace with
to
I replaced it. mod_1 gives set={1,3,5,7,9,...,29}, but ind_1 keeps showing zero.
does not show zero
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:
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.
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