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

 
IgorM:

iHighest and iLowest to help you, and read the algorithm for building ZZ

SZY: not the easiest task, the code will be small, but the algorithm is complex, I can not find the code, but I have so searched for a peak at High: High[iHighest(NULL,0,MODE_HIGH,i)

1. What is "33"?

2. High[iHighest(NULL,0,MODE_HIGH,i) will give one point. How to get the second one?

iLowest != second point.

 
charter:

1. What is "33"?

2. High[iHighest(NULL,0,MODE_HIGH,i) will give one point. How to get the second one?


1. Zig Zag.

2. it won't, it will only give you a possibility to find some High for the upper line and then you will have to choose two of these Highs to draw the line with

 
charter:

The difficulty is finding the points through which the line will later be drawn.

It is not difficult to draw lines when you can see these points. How do you "see" them programmatically?

Thanks, corrected!

 
charter:

The difficulty is finding the points through which the line will later be drawn.

It is not difficult to draw lines when you can see these points. How do you "see" them programmatically?

Thanks, corrected!

 

Good day to all connoisseurs!

Please help me to correct the code in the Expert Advisor https://www.mql5.com/ru/code - Ilan.

The idea is that the EA has an adjustable parameter for equity drawdown, which closes all orders!

However, the locking function appeared later, so our EA has been closing all open orders following the trend and leaves locking positions untouched. So, how to fix it so that all orders are closed at a given drawdown of equity?

Here is the section where the orders are closed (trend and loss orders have different magic numbers). Everything works here. The Expert Advisor is closing all the orders. The drawdown is 4 or more times higher than the set one, up to the point of depot draining:

if (UseEquityStop) {

if (CurrentPairProfit < 0.0 && MathAbs(CurrentPairProfit) > TotalEquityRisk / 100.0 * AccountEquityHigh()) {

CloseThisSymbolAll(MagicNumber);

CloseThisSymbolAll(LMagN);

PrintF("Closed All due to Stop Out");

NewOrdersPlaced = FALSE;

It turns out that the losing orders are being covered but they are not taken into account when the current profit and equity are calculated! Here is the segment that calculates the current profit:

double CalculateProfit() {

double ld_ret_0 = 0;

for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;

if (OrderSymbol() == Symbol())

if (OrderMagicNumber() == MagicNumber || OrderMagicNumber() == LMagN)

if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();

}

return (ld_ret_0);

And here is the segment that calculates equity:

double AccountEquityHigh() {

if ((CountTrades(MagicNumber) == 0) && (CountTrades(LMagN) == 0)) AccountEquityHighAmt = AccountEquity();

if (AccountEquityHighAmt < PrevEquity) AccountEquityHighAmt = PrevEquity;

else AccountEquityHighAmt = AccountEquity();

PrevEquity = AccountEquity();

return (AccountEquityHighAmt);

I highlighted in black the sections I added. What did I forget????? Why doesn't it work?????

 
polsvv:

Good day to all connoisseurs!

Please help me to correct the code in the Expert Advisor https://www.mql5.com/ru/code - Ilan.

The idea is that the EA has an adjustable parameter for equity drawdown, which closes all orders!

However, the locking function appeared later, so our EA has been closing all open orders following the trend and leaves locking positions untouched. So, how to fix it so that all orders are closed at a given drawdown of equity?

Here is the section where the orders are closed (trend and loss orders have different magic numbers). Everything works here. The Expert Advisor is closing all the orders. The drawdown is 4 or more times higher than the set one, up to the point of depot draining:

if (UseEquityStop) {

if (CurrentPairProfit < 0.0 && MathAbs(CurrentPairProfit) > TotalEquityRisk / 100.0 * AccountEquityHigh()) {

CloseThisSymbolAll(MagicNumber);

CloseThisSymbolAll(LMagN);

PrintF("Closed All due to Stop Out");

NewOrdersPlaced = FALSE;

It turns out that the losing orders are being covered but they are not taken into account when the current profit and equity are calculated! Here is the segment that calculates the current profit:

double CalculateProfit() {

double ld_ret_0 = 0;

for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;

if (OrderSymbol() == Symbol())

if (OrderMagicNumber() == MagicNumber || OrderMagicNumber() == LMagN)

if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();

}

return (ld_ret_0);

And here is the segment that calculates equity:

double AccountEquityHigh() {

if ((CountTrades(MagicNumber) == 0) && (CountTrades(LMagN) == 0)) AccountEquityHighAmt = AccountEquity();

if (AccountEquityHighAmt < PrevEquity) AccountEquityHighAmt = PrevEquity;

else AccountEquityHighAmt = AccountEquity();

PrevEquity = AccountEquity();

return (AccountEquityHighAmt);

I highlighted in black the sections I added. What did I forget????? Why does it not work?????

Maybe it should? :

//===================================================================================
double CalculateProfit() 
{
   double ld_ret_0 = 0;
   for (int cnt = 0;  cnt < OrdersTotal(); cnt++) {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()!=Symbol())           continue;
         if (OrderType()>1)                     continue;
         if (OrderMagicNumber()==MagicNumber || 
             OrderMagicNumber() == LMagN)       ld_ret_0 += OrderProfit();
         }
      else if (!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) {
         Print ("Func: CalculateProfit(), Select Order Error = ", GetLastError());
         break;
         }
      }
   return (ld_ret_0);
}
//===================================================================================
 
artmedia70:

Maybe that's the way it should be?

This is how you insert the code so that it can be read
 
eddy:
that's how you put the code in so you can read it.
Oh, yeah? Is that all the difference you could see???
 
Hi all!

Just this weekend I am using the strategy tester for the first time. I can't figure out what use the "Optimisation" function is. I selected different optimisable parameters, but the balance does not change. What is it essentially trying to optimize and how? Does anybody use it at all? :)
 
AndrejFX:
Hi all!

Just this weekend for the first time I'm using the strategy tester. I can't figure out what the use of the "Optimisation" function is. I selected different optimisable parameters, but the balance does not change. What is it essentially trying to optimize and how? Does anybody use it at all? :)

Try using F1 for starters.

Look up User Interface -> Tester.

Maybe https://www.mql5.com/ru/articles/mt4/tester will help

Reason: