Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1204

 
leonerd:

What does the time scale mean in the trading story?

X scale. What do the values on the scale mean?

Tell me, what do the numbers on the chart in the trading statement mean?

 
leonerd:

What do these numbers on the chart in the trading statement mean?

The number of the trade which led to the change in the balance.

 
I didn't get it right away, it's a childish question:

How can I test my TS in MT5 without considering the spread?

In MT4 everything is immediately visible in the tester, in MT5 should I generate a custom Bid symbol?
 
For working with Json, is this the best or is there something newer and more correct?
JSON Serialization and Deserialization (native MQL)
JSON Serialization and Deserialization (native MQL)
  • www.mql5.com
ForecastOscilator_HTF The ForecastOscilator indicator with the timeframe selection option available in the input parameters. Flat_HTF The Flat indicator with the timeframe selection option available in the input parameters. FX5_SelfAdjustingRSI_HTF The FX5_SelfAdjustingRSI...
 
Igor Makanu:
I didn't get it right away, it's a childish question:

How can I test my TS in MT5 without considering the spread?

In MT4 everything is immediately visible in the tester, in MT5 should I generate a custom Bid symbol?

You may try to open the window"Strategy Tester", tab "Settings" - press the button next to the symbol and correct the symbol - set the spread to "0".

 

MT5

Please advise how to implement lot increase depending on balance.

But not by %, but by step by balance growth value.

With each $1000 balance increase I want to increase lot by a step of 0.1

My initial data is thepair EUR/USD

Deposit (initial balance) 1000$

Initial lot 0.1

Need.

If the deposit:

1000 then lot 0.1

2000 then lot 0,2

3000 then lot 0,3

Etc.

I now use this method:

if (Balance>= 1000 && Balance<=2000)  Lot = 0.1;
if (Balance>= 2000 && Balance<=3000)  Lot = 0.2;
if (Balance>= 3000 && Balance<=3000)  Lot = 0.3;

Etc.

But instead of this endless enumeration, I would like to have a function.

I tried to make it up myself, but it didn't work so well.

Perhaps because of problems with normalization...

Please advise, maybe someone has a ready-made solution or an example.

Пара EUR/USD: технический анализ, новости Forex, фундаментальный анализ - Блоги трейдеров и аналитика финансовых рынков
Пара EUR/USD: технический анализ, новости Forex, фундаментальный анализ - Блоги трейдеров и аналитика финансовых рынков
  • www.mql5.com
Валютная пара EUR/USD — самая ликвидная, поскольку в ней участвуют первая и вторая по значимости мировые резервные валюты. Это подтверждается и статистически: доллар и евро самые крупные по объему
 
Vladpedro:

MT5

Please advise how to implement lot increase depending on balance.

But not by %, but by step by balance growth value.

With each $1000 balance increase I want to increase lot by a step of 0.1

My initial data is thepair EUR/USD

Deposit (initial balance) 1000$

Initial lot 0.1

Need.

If the deposit:

1000 then lot 0.1

2000 then lot 0,2

3000 then lot 0,3

Etc.

I now use this method:

Etc.

But instead of this endless enumeration, I would like to have a function.

I tried to make it up myself, but it didn't work so well.

Perhaps because of problems with normalization...

Maybe someone has a ready solution or an example.

Pay attention to the quotient when dividing the deposit by 1000. At a deposit < 2000 there will be 1 integer and some tenths, hundredths... which we are not interested in. The deposit of 2000 will be 2 and so on. It turns out that it is enough to multiply the integer part of this fraction by 0.1 and get what we want.

And in your list there is a mistake, though insignificant. The correct way is as follows

if (Balance>= 1000 && Balance<2000)  Lot = 0.1;
if (Balance>= 2000 && Balance<3000)  Lot = 0.2;
if (Balance>= 3000 && Balance<3000)  Lot = 0.3;
 
Vladpedro:

MT5

Please advise how to implement lot increase depending on balance.

But not by %, but by step by balance growth value.

With each $1000 balance increase I want to increase lot by a step of 0.1

My initial data is thepair EUR/USD

Deposit (initial balance) 1000$

Initial lot 0.1

Need.

If the deposit:

1000 then lot 0.1

2000 then lot 0,2

3000 then lot 0,3

Etc.

I now use this method:

Etc.

But instead of this endless enumeration, I would like to have a function.

I tried to make it up myself, but it didn't work so well.

Perhaps because of problems with normalization...

May be someone has a ready solution or example.

Find rounding using MathCeil,MathRound or MathFloor.

See example how they work:

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property version "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   double start_balance=1000;
   double step_balance=1000;

   Print("Step ",DoubleToString(step_balance,1));

   for(int i=0; i<12; i++)
     {
      double division=start_balance/step_balance;
      Print("Balance ",DoubleToString(start_balance,1),
            ", division ",DoubleToString(division,1),
            ", MathCeil(",DoubleToString(division,1),") ->  ",MathCeil(division),
            ", MathRound(",DoubleToString(division,1),") ->  ",MathRound(division),
            ", MathFloor(",DoubleToString(division,1),") ->  ",MathFloor(division));
      start_balance=start_balance+step_balance/3;
     }
  }
//+------------------------------------------------------------------+

and result.

Step 1000.0
Balance 1000.0, division 1.0, MathCeil(1.0) ->  1.0, MathRound(1.0) ->  1.0, MathFloor(1.0) ->  1.0
Balance 1333.3, division 1.3, MathCeil(1.3) ->  2.0, MathRound(1.3) ->  1.0, MathFloor(1.3) ->  1.0
Balance 1666.7, division 1.7, MathCeil(1.7) ->  2.0, MathRound(1.7) ->  2.0, MathFloor(1.7) ->  1.0
Balance 2000.0, division 2.0, MathCeil(2.0) ->  2.0, MathRound(2.0) ->  2.0, MathFloor(2.0) ->  1.0
Balance 2333.3, division 2.3, MathCeil(2.3) ->  3.0, MathRound(2.3) ->  2.0, MathFloor(2.3) ->  2.0
Balance 2666.7, division 2.7, MathCeil(2.7) ->  3.0, MathRound(2.7) ->  3.0, MathFloor(2.7) ->  2.0
Balance 3000.0, division 3.0, MathCeil(3.0) ->  3.0, MathRound(3.0) ->  3.0, MathFloor(3.0) ->  3.0
Balance 3333.3, division 3.3, MathCeil(3.3) ->  4.0, MathRound(3.3) ->  3.0, MathFloor(3.3) ->  3.0
Balance 3666.7, division 3.7, MathCeil(3.7) ->  4.0, MathRound(3.7) ->  4.0, MathFloor(3.7) ->  3.0
Balance 4000.0, division 4.0, MathCeil(4.0) ->  5.0, MathRound(4.0) ->  4.0, MathFloor(4.0) ->  4.0
Balance 4333.3, division 4.3, MathCeil(4.3) ->  5.0, MathRound(4.3) ->  4.0, MathFloor(4.3) ->  4.0
Balance 4666.7, division 4.7, MathCeil(4.7) ->  5.0, MathRound(4.7) ->  5.0, MathFloor(4.7) ->  4.0

I recommend to useMathFloor.

Документация по MQL5: Математические функции / MathFloor
Документация по MQL5: Математические функции / MathFloor
  • www.mql5.com
Математические функции / MathFloor - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
Files:
1.mq5  3 kb
 
Alexey Viktorov:

Pay attention to the quotient when dividing the deposit by 1000. If the deposit < 2000 will be 1 integer and some tenths, hundredths. which are not of interest. The deposit of 2000 will contain 2 and so on. It turns out that it is enough to multiply the integer part of this fraction by 0.1 and get what we want.

And in your enumeration, albeit minor, there is a mistake. Correct is

Alexey

Thanks. I got the idea of dividing by 1000 and reducing to integer, I'll try to implement it.

<= was set to automatically, not from the code. Writing with my hands, and pens are such ...))

 
Vladimir Karputov:

Select the rounding operation from MathCeil , MathRound or MathFloor.

An example of how they work:

and result.

I would recommend usingMathFloor.

Thank you, just what you need.
Reason: