[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 458

 
Maximov7:
I am trying to write my first Expert Advisor... Please tell me how to fix Ask, declaring it through a variable, and it should be global, because it should be perceived by each special function.... help me please)))

Declare double variable right after external EA parameters, set it to Ask when needed, use it in any function. Although it's more correct to use local variables and pass them as arguments... And understand the scope of variables, it's the basics, you can't do without it anyway.
 

That's the thing I did, but I can't see it inside the start() function, and in the log it says that from the beginning the variable was not assigned an Ask value at that time interval, but just 0.

extern double C1; C1 = Ask;
extern double C2; C2 = Bid;



int start()
{

OrderSend("EURUSD",OP_BUY,0.1,C1,3,Bid-0.0009,Ask+0.0009);

 
double C1; 
// в старте
C1 = Ask;
 
rlx:


To be sure

put Print() where the ClosePosBySizeProfitInPercent("0", -1, Magic, VashParametrPR) function is called; before it.

Parameters are set explicitly. Maybe there are still some undocumented restrictions? For example number of procedures max, or procedure name length? Everything was working. It didn't work after adding a new procedure, but it has a different task.
 

double C1;
// в старте
C1 = Ask;

it is not possible to start because with every new tick a new Ask.... value will be assigned and it has to be reserved for further operation

 
Maximov7:

double C1;
// в старте
C1 = Ask;

you cannot do it at start because every new tick will assign a new value to Ask.... and you need to lock it for further operation

write in init()

but it's not clear why you need Ask from the moment of startup

 

Good day to all!

This is my first time on this forum, I apologize if I wrote in the wrong place.

I need help in adding a virtual TP (in pips and / or when the profit reaches a given value) to my EA.

Please help!

Sincerely Roman.

Files:
bunny_v2.21.ex4  22 kb
 
RomanDD:

Good day to all!

This is my first time on this forum, I apologize if I wrote in the wrong place.

I need help in adding a virtual TP to my EA (in pips and / or when it reaches a given value of profit).

Please help!

Sincerely Roman.

Start writing the code yourself and they will help you here and explain what you do not understand. If you want to order the modification of the Expert Advisor, you have to pay for programming services
 

How much would you estimate the work on my problem?

 

Here is another question .... i have an open order like this:

OrderSend("EURUSD",OP_BUY,0.1,C1,10,Bid-0.0017-0.0017,Ask+0.0017);

how to open another order if this one closes at takeprofit????

Reason: