Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 253

 
Ibragim Dzhanaev:

Can you tell me why the trawl is triggered on every tick?

We have to compare TakeProfit and StopLoss of BUY position with Bid price and SELL position with Ask price.

It's the price at which they are triggered.

So try it like this:
 if(OrderOpenPrice()+(trail_p*Point)<Ask && OrderStopLoss()+(trail_p*Point)<Bid )
if(OrderOpenPrice()-(trail_p*Point)>Bid && OrderStopLoss()-(trail_p*Point)>Ask )
 
Ibragim Dzhanaev:

Can you tell me why the trawl is triggered on every tick?

Trawl template. Right in the same branch.

 
Ivan Ivanov:

It is necessary to compare TakeProfit and StopLoss of a BUY position with the Bid price and SELL position with the Ask price.

These are the prices at which they are triggered.

In other words, try this:

Nothing has changed.

 
Artyom Trishkin:

Trawl template. Right in the same thread.


Thank you.

 
Artyom Trishkin:

Trail template. Right in the same branch.


double sl=NormalizeDouble(level_of_trail-trailing_stop*point,digits);// calculate new stoploss level by value,

Why do you havepoint anddigits written with a small letter ?


 
Ibragim Dzhanaev:

double sl=NormalizeDouble(level_of_trail-trailing_stop*point,digits);// calculate new stoploss level by value,

Why do you havepoint anddigits written with a small letter?


Because the code is optimized, the variable is initialized once in the template, not 100 times in each place

            int    digits=(int)SymbolInfoInteger(symbol_name,SYMBOL_DIGITS);
            double point=(SymbolInfoDouble(symbol_name,SYMBOL_POINT));
 
Ibragim Dzhanaev:

double sl=NormalizeDouble(level_of_trail-trailing_stop*point,digits);// calculate new stoploss level by value,

Why do you havepoint anddigits written with a small letter?


Because they are declared inside this function - this trail template works with any character passed in function parameters, not just the current one, as you might think.

 
Vitaly Muzichenko:

Because the code is optimised and the variable is initialised once in the template, not 100 times in each place

I didn't think about the optimization there, by the way. Surely it is possible to optimise it.
 

advise how to pull quotes for a particular day from the terminal (opening, closing, max, min) to a program written by me (c++) and make the final calculations without returning new information to the terminal to the indicator, adviser, etc., just yank quotes by date to my program ? thanks in advance

 
виталик:

advise how to pull quotes for a particular day from the terminal (opening, closing, max, min) to a program written by me (c++) and make the final calculations without returning new information to the terminal to the indicator, adviser, etc., just yank quotes by date to my program ? thanks in advance

Through a file, for example
Reason: