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

 
DhP:

It's the same, but it's easier (more familiar) to read the code.

I'm too lazy to figure it out, but someone will easily find a mistake in your code without straining. Just wait.

There are no errors there. Everything works fine individually, but I would like to combine everything into one Expert Advisor. At least combine Expert Advisors with lines, the sound signal can also be run separately as a script.
 

Sometimes a message appears in the logbook:

invalid price 1.37197000 for OrderSend function

What could this be about? It appears after the stop loss has been reached.

 

the wrong price is 1.37197000.

the correct price is 1.37197 or 1.3719, depending on which DNS.

To set the number of digits after the decimal point NormalizeDouble() is used

 

How can I trace the opening of a new bar in int start()?

I need the code to be triggered not on every tick but only after a new bar is opened

 

If the time of the bar is not the same, it means that the bar has changed.

if it is not equal, it means the bar has changed - do what you need to do and remember the time.

 

Who has used isCloseLastPosByStop() or isCloseLastPosByTake()? Show how you did it.

 

Could you please advise how to load indicator on a chart programmatically?

There is the function bool ServiceLoadCustomIndicator(int hwndChart,...); //hwndChart- System descriptor of the chart window, where the indicator is loaded.

I don't know how to know the chart window descriptor.

I just need to remember GetTickCount on the first tick after the start of the indicator, but the code below doesn't work - the terminal hangs. Maybe in init() RefreshRates doesn't work at all...?

 while(true){
  if(RefreshRates()) { tik=GetTickCount(); break; }
  Sleep(1); }
 
doon:

Who has used isCloseLastPosByStop() or isCloseLastPosByTake()? Show me how you did it.

It couldn't be simpler:

if (isCloseLastPosByStop(OP_BUY, Magic)) {
// код если последняя поза Бай с магиком Magic закрылась по стоп-приказу
}
if (isCloseLastPosByTake(OP_SELL, Magic)) {
// код если последняя поза Селл с магиком Magic закрылась по тейку
}

Place functions themselves outside of the function start(), you can even at the end of the whole code.

 
todem:

so at least a bit of live video will add to the experience of future programmers here
Your explanation is unsatisfactory. A "live video" with a stupid advertisement for a broker carries nothing but advertisement for the broker.
Your posts are deleted, you have been warned.
 
artmedia70:

This is as easy as it gets:
Place the functions themselves outside of the start() function, or at the very end of the whole code.

I should add that at the same link, where doon took the code of functions, there is an example of test_isCloseLastPosByStop.mq4 script, where everything is done as Artem says. You should have a look at it before you ask.
Reason: