[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 19

 
nadya:
And if I write it as a global variable, should I assign a value directly there?

In these, all the more so because they don't reset to the desired 0 after deinit().

it's better to initialize them in init().

 
nadya:
I have to change the ideology of the program. when the middleSL is sent to stoploss, it is normalized, i.e. rounded to a certain sign, when divided by 2 it will happen so, it is inevitable.
int z;
z=MathMod(Close[0]*10000,2.0);
if ((z==0)&&High[0]>H)
{
H=High[0];
middleSL=OrderOpenPrice()+(Close[0]-OrderOpenPrice())/MIDDLESL;
}

I slightly complicated the code, for the entire transaction from opening to closing only 3 times gave an error, now in real time I will look at the conditions under which they occur, they basically do not bother me, everything works like clockwork, but I'm afraid that the server will banish when I go to a real account

 
nadya:
and if I write it as a global variable, should I assign the value directly there?


You can, but it makes no sense, because it won't be the same as a normal variable. When you drag the svetnik onto the chart, a window will pop up, go to the next tab "Input parameters" and specify the required values, and the svetnik will memorise them

If you want the value to be constant for each cycle of the EA, just enter this immediately after the start, e.g.

int N=5; //одновременно объявляется переменная и присваивается ей значение
double K=3,5; //то же самое
 

please tell me, or i'm about to burst!!!

can an EA delete pending orders because it has insufficient funds?

 
nadya:

please tell me, or i'm going to burst now!!!

can an EA delete pending orders because it does not have enough funds?


if you require it to check the balance and close the order in case of insufficiency, then yes, otherwise it will issue an error or something else, and maybe it will close, but it is always better to provide all options and prescribe it in the code

"ERR_NOT_ENOUGH_MONEY 134 Not enough money to execute a transaction" it can give out this, but will the order be deleted or will it hang around I don't know

 
LazarevDenis:

I made the code a bit more complicated, for the whole transaction from opening to closing it only gave out 3 errors, now in real time I will look at the conditions under which they occur, they do not bother me in principle, everything works like clockwork, but I am afraid that the server will ban when I go to a real account

Yes, it is too complicated, is there such a principled approach?
 
LazarevDenis:

If you require it to check the balance and close the order when there is a deficit, then yes, otherwise it will give an error or something else, or maybe it will close it, but it is always better to consider all options and prescribe it in the code.
I don't really need it, but my orders get deleted in a weird way, I keep looking for an error the whole evening.
 
nadya:
The thing is, I don't really need it, but my orders get deleted in a weird way, I'm looking for an error the whole evening.


i'm sure it's a large lot and not enough free money, or many orders have already been opened (if you let it open more than one).

If you are working in a tester or on a demo, try increasing the amount of money and setting a minimum lot

 
nadya:

please tell me, or i'm going to burst now!!!

can an EA delete pending orders because it has insufficient funds?


yes ! take a look at the log.
 
LazarevDenis:


more than sure that too big a lot is set and he does not have enough free money, or a lot is already open (if you allow him to open more than one order)

if you are working in a tester or demo, try to increase the amount of money and put the minimum lot

i already did that and it worked right away! hurrah!
Reason: