A question for MQL connoisseurs - page 9

 

I'll say it again. Maybe I didn't express myself correctly. I haven't managed to get the multicurrency indicators to work correctly yet. I always have to re-initialize them. Although I have tried different variants. To eliminate the error of division by zero it is usually enough to check for error 4066. If there is one, we exit the function

 
Thank you, Victor. I'll look into it further.
 

Good evening.

I have a problem.

The Expert Advisor opens a position on every bar. Then it closes them when the total profit has been reached.

I need to remove pairwise appearing locks. I have done it this way (I.Kim's function):

 //Закрытие встречных позиций 
if ( NumberOfPositions(NULL, -1,Magic)>=2 ) {//если есть открытые позиции  
if (NumberOfPositions(NULL, OP_BUY,Magic)>=1 && NumberOfPositions(NULL,OP_SELL,Magic)>=1) { 
//если они разнонаправленные
if (NumberOfPositions(NULL,OP_BUY,Magic) == NumberOfPositions(NULL,OP_SELL,Magic)) {
//если имеет место лок, то закрываем :
                    ClosePosFirstProfit(NULL,OP_BUY, Magic);
                    ClosePosFirstProfit(NULL,OP_SELL, Magic);
                                         }}} 
                                         

It works. But this is not how I need it!

I need to delete locked positions only if there are two of them!

And only these two locks should be deleted (i.e. four open positions - two buy and two sell).

And all others (if any) should remain! (this is how it should be)!

I cannot figure out how to do it. Please, tell me how to do it!

 
Rita:

Can it be written in a macive and compared there? Or in global...

Here, it might help.

https://www.mql5.com/ru/articles/1404/page2#4494

https://www.mql5.com/ru/articles/1390

in addition

https://www.mql5.com/ru/forum/118082

 

Help me understand why these results appear...

SymbolEURUSD (Euro vs US Dollar)
Period1 Hour (H1) 2010.01.15 00:00 - 2011.01.14 22:00 (2010.01.15 - 2011.01.15)
ModelControl points (a very crude method, the results must not be considered)
ParametersMagic=212121; Slippage=5; StopLoss=5; MoneyMangement=true; Lots=0.01; MaximumRisk=0.5; Trailing=true; TrailingStop=5; TrailingStep=1; OrderComent="GT2";
Bars in test7201Ticks modelled147186Modelling qualityn/a
Mismatched charts errors1
Initial deposit100.00
Total net profit200349932.50Gross profit512930503.80Gross loss-312580571.30
Profit factor1.64Expected payoff10561.97
Absolute drawdown0.30Maximal drawdown5134616.80 (2.83%)Relative drawdown9.63% (90.27)
Total trades18969Short positions (won %)9692 (35.21%)Long positions (won %)9277 (36.26%)
Profit trades (% of total)6777 (35.73%)Loss trades (% of total)12192 (64.27%)
Largestprofit trade2473457.50loss trade-495931.50
Averageprofit trade75686.96loss trade-25638.17
Maximumconsecutive wins (profit in money)8 (2665.30)consecutive losses (loss in money)13 (-7661.02)
Maximalconsecutive profit (count of wins)6483225.00 (5)consecutive loss (count of losses)-3760440.00 (8)
Averageconsecutive wins1consecutive losses3

Files:
gt2_2.mq4  5 kb
 
rustein:

Help me understand why these results appear...

What exactly is not clear?
 
rustein:

Help me understand why these results appear...

1. your history is not loaded

2. For this TF you need a test at least on all ticks

Here is the correct chart.


And in fact you are using the tester principle of ticks modelling. So there is no surprise at all.

 
MetaDriver:
What's not clear?
I thought the question was clear... Why is it possible for the tester to have such a grail, or is there an error in the EA?
 
rustein:
I thought the question was clear... Why is it possible to make such a grail in the tester, or there is an error in the Expert Advisor?

Because the tester simulates this way.

that's his speciality.

and you use it. You close and open on every tick. but the stoploop is less than the minimum tick movement at the checkpoints.

That's why the profit is drawn.

It has nothing in common with reality.

 
sergeev:

because that's how the tester simulates.

That's its peculiarity.

Thank you, I know it leaks on ticks, what exactly does the tester simulate and how, there are no indicators... Why does it need ticks?

You can put a stop at 50 pips (4 digits), it will also be a grail by the checkpoints....