[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 530

 
Chiripaha:

I set flags for the direction of the trade. Condition: If it falls in one zone between the lines, then buy and do not sell, if in another zone, then do not buy and sell. I regulate this process with horizontal lines.

Before that I ask for the prices of the exposed lines. And after that a block of placing or closing orders - depending on the flag.

The code is trivially simple. But... - Question...

When this design starts working, the buy and sell values turn out to be unpredictable (chaotic). Why does this happen? Because there are clear conditions for the "if" function and "end" and "more/less" operators.

That is, the program behaves according to its own reasons: it either buys or sells, or does nothing regardless of what is written in the values of the variables.


How and what do I need to write to make the conditions work and, most importantly, to make them work? What am I doing wrong and what am I not taking into account? (I think I have mentioned everything I need in the function conditions).


There is also another issue in this topic: when variables change depending on the conditions, their values in Expert Advisor settings (when accessing them via F7) will be the same as they were set by the user. That's why it's impossible to see the current state of these variables. How can we make it so that we can see what their values are at the moment?


How do you draw lines? Where do you check, in the tester or in the demo?
 
Vinin:

How do you draw lines? Where do you check, in the tester or on the demo?

I've been trying to overcome this for 2 weeks now - i.e. I've tried many things (including writing 3 variants of a similar robot - but the problem is the same).

I set the lines manually (regular horizontal lines) - Then I ask the price of those lines - If the price falls in the range between 2 lines, then a flag should be triggered (buy or sell - I get a maximum of 4 flag variants for each pair of lines).

The names of the lines are identical to the names of the variables, only without the letter "p" (indicating "price").

I checked with the tester and with the demo - the results are the same.

For testing - simplified the variant to a minimum - up to 2 pairs of lines (for buying and for selling) - a bug still appears.

The fewer combinations of lines, the less the problem occurs (but it does not disappear - it's a false sense). The more variations, the more the problem is more prominent.


PS

One of the variants of the robot (the primary one was just that), when setting the line, automatically set 2 additional lines. And here the bug did not come out. But as soon as I tried to set all the lines manually, this bug began to appear. - It means that before I had time to set additional lines (level - baseline) the robot started to trade at its sole discretion (both in the Strategy Tester and in the demo).

 

Good day and good trading to all!

A word of advice plz, my head is not clear, I am a beginner...

I am a beginner, I am very new to this kind of thing:

I put two pending orders

I have to first select each of them one by one and modify them, BUT I don't know the position number of these orders or their ticker... how do i know the ticker of each position?

 

What function can I use to terminate/terminate the Expert Advisor in the event of certain conditions?

In other words, my Expert Advisor works, but in case of any failure (this point I have already written), a function must be executed that closes the Expert Advisor and it stops working and trading.

 
Ekburg:

What function can I use to terminate/terminate the Expert Advisor in the event of certain conditions?

I.e., my Expert Advisor works, but in the case of any failure (this point I have already written), there should be a function that closes the Expert Advisor and it stops working and trading.

First of all, we have to define "WHAT EVERYONE should do" when the "rush hour" occurs - the mentioned conditions. If you just stop trading, you can do this:

bool STOP = false;
int start()
{
    //---- В самом начале кода
    if (STOP) return (0);
    //---- код советника
}
 
TarasBY:

The first thing to do is to determine "WHAT exactly" the EA should do when the "rush hour" occurs - the conditions mentioned. If you just stop trading, you can do this:


i.e., it is enough to add the function return(0) to stop working of the Expert Advisor?
 
Ekburg:

i.e. it is enough to add the function return(0) to terminate the Expert Advisor?
when the condition you mentioned occurs.
 
TarasBY:
on the occurrence of the condition you mentioned.

Thank you, is there an answer to the question I asked earlier?)
 
Ekburg:

Thank you, is there an answer to the question I asked earlier?)
I don't know where to start in the alphabet... Get some EA codes from the codebase, one of them MUST have a ready answer to your question.
 
Dimka-novitsek:

At first glance, it's probably about the variables, not the conditions. I would start by outputting the variables with alerts, as the code itself looks NORMAL !!!

Alert(" pcb " , pcb ); Alert(" pl " , pl ); Alert(" pb " , pb );


You were right - it was about the prices requested. In my inexperience I checked them on exposed lines, and those that were missing (because they weren't there - human logic), I didn't check them either.

And they, even with an error 4202, but the price they assigned - 0.0000 - and it was this price and ruined all tidbits! : ))))


Thank you very much Vinin and TarasBY !