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

 
Igor Makanu:

I doubt I can explain, if that's what you're asking

object is ... let's say a variable of class type

in your code section is class CProgram

somewhere in your code it must say

and will need to be called

You are GOD!!! I understood you and it all worked out)
 

Can you tell me what it means?

return value of'OrderSend' should be checked TestLibrary.mq4 64 6

 
MakarFX:

Can you tell me what it means?

return value of 'OrderSend' should be checked TestLibrary.mq4 64 6

The result of OrderSend should be checked. :-)

 
Maxim Kuznetsov:

OrderSend result must be verified. :-)

I know English)))

how to check it?

 
MakarFX:

I know English)))

How do you check it?

result=SomeOperation(....)

if (result!=ok) {

Print("Error");

}

 
Maxim Kuznetsov:

result=SomeOperation(....)

if (result!=ok) {

Print("Error");

}

Thank you
 
//+------------------------------------------------------------------+
//| TEST_V01.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#define MAGICMA 20131111
//--- Inputs
input int Risk = 1;
input int Max_Risk = 8;
input int SL = 100;
//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(OrdersTotal()==0)
if(OrderSend(Symbol(), OP_BUY, Lot_Calculate(Symbol(), Risk, Max_Risk, SL), Ask, 30, NormalizeDouble(Ask - SL*Point, Digits), NormalizeDouble(Ask + SL*Point, Digits),",MAGICMA,0,Blue)==-1)
Print("Error: ",GetLastError());
}
//+------------------------------------------------------------------+
//-----------------------------------------------------------------
// Lot_Calculate |
//-----------------------------------------------------------------
double Lot_Calculate(string _symbol, int _risk, int _m_risk, int _pips)
{
_m_risk = Max_Risk;
_pips +=20;
double minlot = MarketInfo(_symbol,MODE_MINLOT);
double maxlot = MarketInfo(_symbol,MODE_MAXLOT);
double steplot = MarketInfo(_symbol,MODE_LOTSTEP);
double money_risk = NormalizeDouble(AccountEquity()*_risk/100,2);
double calk_pip_cost = NormalizeDouble(money_risk/_pips,2); // cost per point
double lot_pip_cost = MarketInfo(_symbol,MODE_TICKVALUE); // the cost of one pip at a price change by volume of one standard lot
// while(!MathIsValidNumber(lot_pip_cost || lot_pip_cost ==0)
//{
// lot_pip_cost = MarketInfo(_symbol,MODE_TICKVALUE);
//}
double lot = calk_pip_cost/lot_pip_cost;
//-------------------------------------------------------------
double money_m_risk = NormalizeDouble(AccountEquity()*2*_risk/100,2); // I also double the risk
double _m_calk_pip_cost = NormalizeDouble(money_m_risk/_pips,2); // calculation of one point value after doubling
double lot_m = _m_calk_pip_cost/lot_pip_cost; // calculation of lot after doubling
if(lot <= minlot) lot = minlot;
else if(lot >= maxlot) lot = maxlot;
else if(lot > minlot && lot < maxlot)
{
int k = int((lot - minlot)/steplot);
lot = NormalizeDouble(minlot+k*steplot,2);
}
return(lot);
// ------------------------------------------------------
{
if(lot_m <= minlot) lot_m = minlot; // from this line, my self
else if(lot_m >= maxlot) lot_m = maxlot;
else if(lot_m > minlot && lot_m < maxlot)
{
int k = int((lot - minlot)/steplot);
lot_m = NormalizeDouble(minlot+k*steplot,2);
}
return(lot_m);
if(OrderProfit()>0) lot--;
if(OrderProfit()<0) lot_m++;
}
if(_m_risk == Max_Risk) lot_m = lot; // you can not understand anything here
return(0);

}


I have been struggling with this for two days. I cannot write the function that recalculates the risk.

If a trade is closed by TP, the risk will remain the same.

If the risk is closed by SL, the risk is increased by 2 times and so on, up to the value prescribed in the input variables of the Expert Advisor, say Max_Risk = 8;

and then reset to the initial risk Risk = 1;

Well, if after doubling the trade is closed at TR, we again return to the initial Risk = 1;

Can you help?

Thank you in advance.

Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • www.mql5.com
Задавайте вопросы по техническому анализу, обсуждайте торговые системы и улучшайте свои навыки программирования торговых стратегий на языке MQL5. Общайтесь и обменивайтесь опытом на форуме с трейдерами всего мира и помогайте ответами новичкам — наше сообщество развивается вместе с вами. и снова dll и маркет День добрый! Правило №1 dll на...
 
That's not it at all.
 

Good afternoon!

Professionals please help. I can't solve one problem. Here is the code:


datetime some_time=TimeCurrent();

int start()

{

double summ;

double razn;

int k=iBarShift(",PERIOD_M5,some_time);

double VAL0=MathAbs(iATR(NULL,0,1,1))/Point;

double VAL1=MathAbs(iATR(NULL,0,1,0))/Point;

if (VAL1>VAL0)

{

razn =MathAbs((iATR(NULL,0,1,0))-(iATR(NULL,0,1,1))/Point;

for(int i = k; i >= 1; i--)

{

summ=summ+razn;

}

Comment("Used periods: ",k,"\n,

"ATR previous: "+VAL0+"\n",

"ATR current: ",VAL1,"\n",

"ATR difference: ",razn,"\n",

"ATR difference: ",summ,"\n");

}

return(0);

}

The idea is the following: the Expert Advisor counts the difference between the current ATR value and the previous one. But only with increasing ATR.

This difference is displayed in the variable "razn". I need the value of the variable "razn" to be added/cumulated to the variable "summ" with each arrival of a new bar.

In the current version accumulation of "summ" does not work correctly.

I suspect it's about loops.


Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Периоды графиков
Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Периоды графиков
  • www.mql5.com
Все предопределенные периоды графиков имеют уникальные идентификаторы. Идентификатор PERIOD_CURRENT означает текущий период графика, на котором запущена mql5-программа.
 
Good afternoon to forum members. I can't find any information. Is there any tool that automatically draws lines (not horizontal) from lows and highs to a certain point level? In other words, do you define the low or high and draw the line to the candlestick that fixes the distance in pips from the high or low? I found that the Fractal indicator does low and high determination. But I have not been able to find such an add-on allowing me to draw a line to the point of price change by a certain number of points.