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

 
Igor Makanu:

everything needs to be fixed.

Your code searches for the first found order from the order history with the given symbol and the given magician

then count the number of unprofitable orders found and multiply to the power of 2 this number of orders

search the forum for"useful functions from CMM" and do something like this

- find the ticket of the last order for our symbol and our magik

- obtain OrderProfit() and OrderLots() from the found ticket and multiply by your martingale coefficient, if necessary

ZS: there may be a ready solution

The problem is a bit different, I have a floating lot on each opening and need to multiply it by the coefficient.
The lot of the first knee for example 0.07, and the second may be 0.04, after a loss the lot of the third knee 0.05 and here is this lot and need to be multiplied by coefficient 4.
My function calculates a floating lot, it needs to be multiplied by LotSize() * 2,4,8,16 etc.
 
Denis Pershin:
The task is a bit different, I have a floating lot at every opening and I need to multiply it by a coefficient.
The lot of the first knee for example 0.07, and the second may be 0.04, after a loss the lot of the third knee is 0.05 and this lot should be multiplied by coefficient 4.
My function calculates a floating lot, it needs to be multiplied by LotSize() * 2,4,8,16 etc.

such

If you know the starting lot, you can use the last losing order to check its lot and calculate the knee number, and if the order is in profit, you start with the starting lot again

learn to find the last closed order with your magician

if the system of lot calculation is very complex - the option of a magician + the knee number for new orders, you can also use comments, but not very reliable, better use several magicians


Your code just goes through the orders - it does not see anything, that is why I paid attention to it

 
Igor Makanu:

like this

If you know the starting lot, then you can use the last losing order to check its lot and calculate the knee number, and if the order is in profit, you start with the starting lot again

learn to find the last closed order with your magician

If the system of lot calculation is quite complex - the option of a magician + the number of a knee for new orders, you can also use comments, but not reliably, better use several magicians


Your code just goes through the orders - it does not see anything, that's why I paid attention to it

That is the difficulty: the starting lot is unknown and is calculated based on n% of equity.
I would not like to use the comment.
Now the number of successive losses is calculated in the code and it is considered correctly but I cannot decide how to improve it using multiplication coefficients of 2,4,8,16.
 
Denis Pershin:
The code now counts the number of consecutive losses and counts correctly, but how to do it with a multiplication factor of 2,4,8,16 I can't figure out.

not right

But if it suits you, then try to fix your code that way.

int c=1;
....
c*=2; // 1,2,4,8....
 
Igor Makanu:

wrong

but if it suits you then try to correct your code like this

He will get at the third multiplication: 3*2=6, and he already needs 8, and the fourth will be 8, and he needs 16.

 

k = {1,2,4,8,16,......}

cn = k[c]

 
Vitaly Muzichenko:

He will get at the third multiplication: 3*2=6, and he already needs 8, and at the fourth multiplication he will get 8, and he needs 16.


void OnStart()
{
   int c = 1;
   for(int i = 1; i <= 5; i++)
   {
      c *= 2;
      printf("i = %i, c = %i",i,c);
   }
}

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 1, c = 2

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 2, c = 4

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 3, c = 8

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 4, c = 16

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 5, c = 32

where is 6?

or what is it?

 
Igor Makanu:


2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 1, c = 2

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 2, c = 4

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 3, c = 8

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 4, c = 16

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 5, c = 32

where is 6?

or what is it?

yeah, i got it wrong.

 
Does MQ plan to add custom indicators to the mobile platform?
 
Igor Makanu:


2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 1, c = 2

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 2, c = 4

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 3, c = 8

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 4, c = 16

2020.11.08 11:28:09.527 tst (EURUSD,H1) i = 5, c = 32

where is 6?

or what is needed?

Thank you, very helpful)

Reason: