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

 
Lians:

TarasBY, thanks for the explanations and the function!

I'm taking the function to my collection, but I don't understand something:

If the parameter fi_LevelBU is negative, it means shift of the TP to profit, while if it is positive, it means profit or vice versa?

Correct (not vice versa).

Lians:

And the second: is it better to check for constraints within the function itself or outside the function?

Everyone decides for himself. I have created a library that is responsible for executing trade orders and checks for all limitations.

P.S. There was a small error in the function code (extra parenthesis) - I fixed it.

 

Guys, advise how to fix the problem

If you use in the Expert Advisor

while(!IsStopped())

then for some reason advisor continues to work even when the button "advisors" is released I need it to be disabled and when I use this cycle when an EA is working it is impossible to open properties of the EA, may be someone knows how to fix the EA ????? I know about sleep(......);

 
VOLDEMAR:

Guys, advise how to fix the problem

If you use in the Expert Advisor

then for some reason advisor continues to work even when the button "advisors" is released I need it to be disabled and when I use this cycle when an EA is working it is impossible to open properties of the EA, may be someone knows how to fix the EA ????? I know about sleep(......);

Maybe it is not this loop that "locks" the EA!
 
TarasBY:
Perhaps it's not this cycle that's "looping" the EA!
I think not, as only one cycle is used to count orders
 
VOLDEMAR:
I think not, as there is only one cycle for counting orders

Would it be better to use such a construction:

if (!IsStopped())
{
   // ...
}
 
paladin80:

It might be better to use a design like this:

then there is no desired result .... This loop is specially applied .... The EA receives one tick and runs without ticks in a specially looped loop
 
VOLDEMAR:
then there is no desired result .... This loop is specifically applied to .... The Expert Advisor receives one tick and works without ticks in a special loop

Hmm, interesting task. Maybe we should make the EA dependent on tick arrival after all. I think that after the first tick the EA will not care about the signal to turn it off. Try to use a for loop:

if (!IsStopped())
{  for (int i=0; i=10000; i++)
   {
      // ...
   }
}

When the EA has worked 10,000 times (or any other number of times that you need), then it will wait for a new tick to come in order to start the loop again. And if at this point, it receives a signal to stop working, it should switch off. It will be interesting to see if this works.

 

TarasBY, thanks again))

For me such libraries are still "tough", but I'll try to figure it out))

 
VOLDEMAR:
I think not, because then only one cycle is used to count orders
How about this?!
 
Good evening! Question, if I use an EA. Will my brokerage company be able to see the algorithm of its work and how it calculates values (indicators, analysis of historical data), i.e. the whole code of the Expert Advisor? Or does my brokerage company only get information about commands: opening, modification and closing of positions?
Reason: