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

 
deyron:
Hello. Can you please tell me if one EA is attached to several windows of currency pairs at once, then changes in the EA in one window affect the EA in another window??? i.e. local variables change or not???


If you change the magik for the same EA, then EAs will work separately each in its own window.

 

I REALLY NEED HELP IN REDESIGNING MY EA!!!

I'm happy with everything in it, just wish I could.... If you can not translate a deal to breakeven or close at take profit, then close it on the opposite of a new signal to open without changing the trading strategy. For example, if Sell deal turned around and Owls did not transfer it to Breakeven, he starts a new candle to open a Sell deal with increasing volume hoping for a pullback, and I want him to keep working as if he closed the deal at Stop Loss/Take... if the price reverses, it opens buy, and closes that one, albeit with a big minus.... Like this

/*decompiled deleted*/

 
deyron:
Hello. Can you please advise if one EA is attached to several windows of currency pairs, then changes in the EA in one window affect the EA in another window??? i.e. local variables change or not???
No, they do not affect each other. The same position magic can only be harmful when the EA determines the position close only by magic.
 

Good day to all. Please help me understand global variables. The problem is something like this: I have a variable bool line_1=false; it changes to true; when reaching a price and make levels of reaching which will be other actions and bool line_1 again becomes false; i need to restart the system or the parameters will not be reached on friday night, the values of this variable are lost and will affect the outcome of trading, as i understand i need to make them global bool variables. i have not done anything about it yet and i need your advice if i think i am going to make corrections in the code, please tell me if anything needs to be corrected, thanks.

bool line_1=GlobalVariableGet(false);

if(macd_2<0&&macd_1>0) {line_1=GlobalVariableSet(true);}

if(macd_2>0&&macd_1<0) {line_1=GlobalVariableSet(false);}

If the code is built in such a way, then when restarting the terminal, will the variable leave its previous value at the moment of restarting or will it be reset to the state declared at the beginning of the program? Thanks again!

 
paladin80:
No, they do not affect each other. The same position magic can only be detrimental when the EA determines the position closure by magic only.

Yes, you can, of course, filter differently. For example, by symbol, etc. I said the simplest option.
 
laveosa:

good day all. please help me understand global variables. the problem is something like this: i have a variable bool line_1=false; it changes to true; when reaching a price and make levels of reaching which will be other actions and bool line_1 again becomes false; i need to restart the system or the parameters will not be reached on friday night, the values of this variable are lost and will affect the outcome of trading, as i understand i need to make them global bool variables. i have not done anything about it yet and i need your advice if i think i am going to make corrections in the code, please tell me if anything needs to be corrected, thanks.

bool line_1=GlobalVariableGet(false);

if(macd_2<0&&macd_1>0) {line_1=GlobalVariableSet(true);}

if(macd_2>0&&macd_1<0) {line_1=GlobalVariableSet(false);}

If the code is built in such a way, then when restarting the terminal, will the variable leave its previous value at the moment of restarting or will it be reset to the state declared at the beginning of the program? Thanks again!

First, read about GlobalVariableSet() - you lack parameters and use it incorrectly.

And sequence of operations is as follows: when value of variable you want to save changes, this value is passed to appropriate global variable of terminal using this function. And when reinitializing the EA in init(), you pass its value to the variable via the GlobalVariableGet() function.

 

Gentlemen, please give me a hint!

I am trying to implement a simple idea, which is described in the comments to the program.

The program opens orders in the TESTER at a price that is not coinciding with those specified in the code.

For example, the order opens at the price of 0.86084, while the closest value in the array is 0.85375.

The difference is positive while the code specifies to open orders if the difference is < 0.00000, i.e. negative.


Please advise us where the error is located.

Thank you.

int start()
{
 double Price=iOpen (Symbol (),0,0);        
 double SL=NormalizeDouble (Price-3000*Point, Digits);         
 double TP=NormalizeDouble (Price+100*Point, Digits);    
 #include <MASSIV.mqh> //объявление массива типа double (неповторяющиеся значения цены с пятью знаками после точки)
 double value =  Bid ;//параметру value функции ArrayBsearch присваивается значение  цены последнего тика

 int S = ArrayBsearch(  massiv,  value, WHOLE_ARRAY,  0, MODE_ASCEND);//функция возвращает индекс значения цены макс. близкой к цене последнего тика 
 if( (NormalizeDouble (Bid-massiv[S],Digits) <=0))//если разница между значением массива возвращенным на последнем тике и ценой последнего тика отрицательная или = 0.00000


{
                        
 OrderSend(Symbol(),OP_BUY,0.1,Ask,1,SL,TP,"jfh",123 );//ордер открыть
 
solnce600:

Gentlemen, please give me a hint!

I am trying to implement a simple idea, which is described in the comments to the program.

The program opens orders in the TESTER at a price that is not coinciding with those specified in the code.

For example, the order opens at the price of 0.86084 with the closest value 0.85375 in the array.

The difference is positive, whereas the code specifies to open orders if the difference is < 0.00000, i.e. negative.

Please advise us where the error is located.

Thank you.

The best way to find the error is to go through each line from the bottom up and see how it corresponds to what you want to get and what is written.

if ((NormalizeDouble (Bid-massiv[S],Digits) <=0))
//если разница между значением массива возвращенным на последнем тике и ценой последнего тика отрицательная или = 0.00000
This condition presupposes that... - Is this what you intended??? (1 - 1000000 <= 0) - satisfies???

I gave you a solution and you "passed it by"...

 
TarasBY:

The way to find mistakes: go through each line from the bottom up and realise the correspondence between what you wanted and what is written.

This condition assumes that... - Is this what you intended? (1 - 1000000 <= 0) - does it satisfy???

I gave you a solution and you "passed it by"...

Thank you very much. I even copied your hint for myself.... I just didn't fully understand it..... excuse my stupidity .... I'll rack my brains and try to figure it out.

I just don't understand why you take Bid variable value (price of the last tick) as 1. I assume it's a 6 digit value with a decimal point after the first one... and the value of

Please tell me what I may misunderstand.

I have studied your code carefully.

double ld_Delta = 10. * Point;
if (NormalizeDouble (MathAbs (Bid - Price), Digits) <= ld_Delta)//
and this price is the open price of a new bar
{OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123);}//openthe order


But I don't understand

-Why do you suggest using the variable Price instead of variable massiv[S] ? It contains the open price of the last bar.

My idea is that one of the necessary conditions for opening an order is coincidence of its open price with one of the array values closest to the price of the last tick.

My strategy in full looks like this

OPEN ORDER if 2 conditions are met at the same time

-The open price of the last candle

at the price closest to one of the array values (array values - about 2000 non-repeating Bid price values going in random order)

I will be very grateful to you for help and hint - but I have been puzzling for the second day ..... and all to no avail.


	          
 
solnce600:

Thank you very much. I even copied that tip of yours.... I just didn't fully understand it..... sorry for the stupidity .... I'll rack my brains and try to figure it out.

I just don't understand why you take Bid variable value (price of the last tick) as 1. I assume it's a 6 digit value with a decimal point after the first one... and the value of

Please tell me what I may misunderstand.

I have studied your code carefully.

double ld_Delta = 10. * Point;
if (NormalizeDouble (MathAbs (Bid - Price), Digits) <= ld_Delta)//
and this price is the open price of a new bar
{OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123);}//openthe order

But I don't understand

-Why do you suggest using the variable Price instead of variable massiv[S] ? It contains the open price of the last bar.

My main idea is that one of the necessary conditions for opening an order is coincidence of its open price with one of the array values closest to the price of the last tick.

My strategy in full looks like this

OPEN ORDER if 2 conditions are met at the same time

-The open price of the last candle

at the price closest to one of the array values (array values - about 2000 non-repeating Bid price values going in random order)

I will be very grateful to you for help and hints - I've been puzzling over ..... for the second day, but it has no effect.

To understand what's going on, I need to get the calculations out to the printer:

    //если разница между значением массива возвращенным на последнем тике 
    // и ценой последнего тика отрицательная или = 0.00000
    if ((NormalizeDouble (Bid-massiv[S], Digits) <= 0))
    {
        Print ("massiv[", S , "] = ", massiv[S], " | massiv[", S - 1, "] = ", massiv[S-1], " | massiv[", S + 1, "] = ", massiv[S+1], " | Bid = ", Bid);
        OrderSend(Symbol(),OP_BUY,0.1,Ask,1,SL,TP,"jfh",123 );//ордер открыт
    }
and analyse the results.
Reason: