Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 95

 
hoz:

Yes. Variables with i_ are input variables (from the word intut, which can be changed by the user...), and pt is a global variable too, which is visible everywhere...

No, the lot has not been normalised. Never encountered it in tester... And what does lot have to do with the object (error 4200)?

What does lot have to do with it? If the lot is invalid, the error handling function is called, which will cause objects to be built.

If the lot is wrong, there will be an error in the tester. You say that you don't build objects, but in the function

void pr (string txt)

still builds objects:

if(info[i]!=""){
cm=info[i];
ObjectCreate ("txtw"+i,OBJ_LABEL,0,0,0);
ObjectSet    ("txtw"+i,OBJPROP_CORNER,1);
ObjectSet    ("txtw"+i,OBJPROP_XDISTANCE,10);
ObjectSet    ("txtw"+i,OBJPROP_YDISTANCE,30+15*i);
ObjectSetText("txtw"+i,cm, 10, "Times New Roman", Green);}

That's probably where the bug is buried. You may have to do something there. Comment out the output of the chart in this function. If the error is gone, you are looking for the reason behind it in the function.

void pr (string txt)
 
vovak_85:

Hello, I am new to mql programming. I have a problem, I have a custom indicator, not written by me, it generates buy and sell signals in the form of arrows, for this purpose there are two buffers in the indicator, the problem is that I can not properly read the signals from the indicator to the Expert Advisor to make a buy or sell.

The code for the indicator:

...

To paste the code correctly in the forum click on the SRC and then copy the code.

 

SRC to insert code!!!

and it's not a hindrance, it's highly recommended!

Forum navigator and answers to frequently asked questions. Highly recommended reading! ( 1 2 3 4 5 6 ) 52 18.02.2011 FAQ

 

Hello, I am new to mql programming. I have a problem, I have a custom indicator, not written by me, it generates buy and sell signals in the form of arrows, for this purpose there are two buffers in the indicator, the problem is that I can not properly read the signals from the indicator to the Expert Advisor to make a buy or sell.

Indicator code:

#property indicator_chart_window

#property indicator_buffers 7

#property indicator_color1 Red

#property indicator_color2 MediumBlue

#property indicator_color3 Red

#property indicator_color4 MediumBlue

#property indicator_color5 Blue

#property indicator_color6 Red

#property indicator_color7 Blue


extern int MM = 3;

extern int MP = 20;

double a[];

double b[];

double c[];

double d[];

double e[];

double g[];

double h[];

int x = 0;


int init() {

SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1, Red);

SetIndexBuffer( 0, a );

SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 1, MediumBlue);

SetIndexBuffer(1, b);

SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2, Red);

SetIndexBuffer(2, c);

SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 2, MediumBlue);

SetIndexBuffer(3, d);

SetIndexStyle(4, DRAW_ARROW, STYLE_SOLID, 3);

SetIndexBuffer(4, e);

SetIndexArrow(4, 233);

SetIndexStyle(5, DRAW_ARROW, STYLE_SOLID, 3);

SetIndexBuffer( 5, g );

SetIndexArrow(5, 234);

SetIndexStyle(6, DRAW_ARROW, STYLE_SOLID, 3);

SetIndexBuffer(6, h);

SetIndexArrow(6, 233);

SetIndexDrawBegin(0, 5);

SetIndexBuffer( 0, a );

SetIndexBuffer(1, b);

SetIndexBuffer(2, c);

SetIndexBuffer(3, d);

return (0);

}


int deinit() {

return (0);

}


int start() {

double qw;

double qe;

double qr;

double qt;

double as;

double ad;

double af;

double ag;

int i,razmer;


if (Bars <= 10) return (0);

x = IndicatorCounted();

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

if (x > 0) x--;

for (int zx = Bars - x - 1; zx >= 0; zx--) {

qw = iMA(NULL, 0, MP, 0, MM, PRICE_CLOSE, zx);

qe = iMA(NULL, 0, MP, 0, MM, PRICE_LOW, zx);

qr = iMA(NULL, 0, MP, 0, MM, PRICE_OPEN, zx);

qt = iMA(NULL, 0, MP, 0, MM, PRICE_HIGH, zx);

as = (c[zx + 1] + (d[zx + 1])) / 2.0;

ag = (qw + qt + qr + qe) / 4.0;

ad = MathMax(qt, MathMax(as, ag));

af = MathMin(qr, MathMin(as, ag));

if (as < ag) {

a[zx] = af;

if (a[zx] < b[zx] && a[zx + 1] < b[zx + 1] && a[zx + 2] > b[zx + 2] && a[zx + 3] > b[zx + 3])

e[zx] = af - 10.0 * Point;

else{

razmer=ArrayRange(4,1);

for (i=1;i<razmer;i++)

e[i]=0; }

b[zx] = ad;

} else {a[zx] = ad;

b[zx] = af;

if (a[zx] > b[zx] && a[zx + 1] > b[zx + 1] && a[zx + 2] < b[zx + 2] && a[zx + 3] < b[zx +

3]) g[zx] = af + 10.0 * Point;

}

c[zx] = as;

d[zx] = ag;

}

return (0);

}
Код советника для получения значений из индикатора и совершения сделки
double L_B=iCustom(0,0,"Makedonskii",MM,MP,0,4);

double L_S=iCustom(0,0,"Makedonskii",MM,MP,0,5);

if (L_B!=0) Ticket=OrderSend (Symbol(), OP_BUY, Lot, Ask, 10, Bid - 15*Point, Ask + 15*Point, "", MagicNumber, 0, Green);

if (L_S!=0) Ticket=OrderSend (Symbol(), OP_BUY, Lot, Bid, 10, Ask + 15*Point, Bid - 15*Point, "", MagicNumber, 0, Green);
Кому несложно подскажите как правильно получать значения на покупку и продажу
 
vovak_85:
I'll know, thank you! Fix it?
Correct in your previous post.
 
vovak_85:
I'll know, thank you! Fix it?
Of course! By removing an unnecessary spoilsport!
 
hoz:

pr is a print function. And the error, this is already a standard constant. Logically, this is not acceptable at all. If you still suspect the pr function, here it is:


Well, replace it with the usual print and watch the log.

there object is created, object name is not unique, that's why there is an error when creating an object.

 
artmedia70:

What does this have to do with the lot? If lot is wrong, then error handling function is called and it will cause building objects.

If the lot is wrong, there will be an error in the tester as well. You say that you don't build objects, but in the function

objects are still being built:

That's probably where the problem lies. You may have to do something there. Comment out the output of the chart in this function. If the error is gone, you are looking for the cause of the error in the function



I had already thought of that myself, and your answer just hit the same spot. The problem disappeared with commenting out places with this function. Apparently, when using it, you have to delete all objects in the input at once, right? I.e. at the very beginning of the pr function, I mean.
 
hoz:

I've already thought about it myself, and just now your answer hit the same point. The problem disappeared with commenting out places with this function. Apparently, when using it, you have to delete all objects on the input at once, right? I.e. at the very beginning of the pr function, I mean...

I honestly don't know the logic of your function. Whether it should delete objects or build them, I don't know. Tell me what you want it to do and we'll see where the logic is wrong. However, if the function tries to build a graphical object but fails, it means it already exists. So what next according to the logic of your program? You can build a new object with a different name (for example, add the current time to the object name (TimeToStr(TimeCurrent()))) or, if you already have an object but need to change its properties, do not build it again, but simply change its properties. Then the error will not appear again.

It's as simple as that. The main thing is to know what you want. :)

 
vovak_85:

Hello, I am new to mql programming. I have a problem, I have a custom indicator, not written by me, it generates buy and sell signals in the form of arrows, for this purpose there are two buffers in the indicator, the problem is that I can not properly read the signals from the indicator to the Expert Advisor to make a buy or sell.

Indicator code:


Are you sure you have all curly brackets in place. They are missing in some places. That's why your logic is flawed. And most likely the result is not what you expected.
Reason: