Maybe there is a function in MQL5? I want to understand why I get this message 2021.02.08 21:29:20.876 my_first_ea_sartrailing (BRN,M5) Alert: Request to place Sell order failed - error code:4756
//--- собираем все вместеif(Sell_Condition_1 && Sell_Condition_2)
{
if(Sell_Condition_3 && Sell_Condition_4)
{
// есть ли в данный момент открытая позиция на продажу?if(Sell_opened)
{
Alert("Уже есть позиция на продажу!!!");
return; // не добавлять к открытой позиции на продажу
}
mrequest.action = TRADE_ACTION_DEAL; // немедленное исполнение
mrequest.price = NormalizeDouble(latest_price.bid,_Digits); // последняя цена Bid
mrequest.sl = NormalizeDouble(latest_price.bid + STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble(latest_price.bid - TKP*_Point,_Digits); // Take Profit
mrequest.symbol = _Symbol; // символ
mrequest.volume = Lot; // количество лотов для торговли
mrequest.magic = EA_Magic; // Magic Number
mrequest.type= ORDER_TYPE_SELL; // ордер на продажу
mrequest.type_filling = ORDER_FILLING_FOK; // тип исполнения ордера - все или ничего
mrequest.deviation=100; // проскальзывание от текущей цены//--- отсылаем ордерOrderSend(mrequest,mresult);
// анализируем код возврата торгового сервераif(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed
{
Alert("Ордер Sell успешно помещен, тикет ордера #:",mresult.order,"!!");
}
else
{
Alert("Запрос на установку ордера Sell не выполнен - код ошибки:",GetLastError());
return;
}
}
}
return;
}
Maybe there is a function in MQL5? I want to understand why I get this message 2021.02.08 21:29:20.876 my_first_ea_sartrailing (BRN,M5) Alert: Request to place Sell order failed - error code:4756
Please tell me how to interpret this line in the code -- CParabolicStop *SARTrailing[];
CNRTRStop *NRTRTrailing[]; I understand that CParabolicStop and CNRTRStop are classes, * pointer, arrays SARTrailing[] and NRTRTrailing[] But what do these strings mean? The article of this advisorhttps://www.mql5.com/en/articles/134 it says that this is --- How do I understand this? And where exactly are these arrays created? Can I really load classes into arrays, or objects of classes? And what is it for in practical terms?
//+------------------------------------------------------------------+//| Sample_TrailingStop.mq5 |//| MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright"MetaQuotes Software Corp."#property link"http://www.mql5.com"#property version"1.00"#include <Sample_TrailingStop.mqh> // подключение класса трейлинга//--- input parametersinputdouble SARStep = 0.02; // Шаг Parabolicinputdouble SARMaximum = 0.02; // Максимум Parabolicinputint NRTRPeriod = 40; // Период NRTRinputdouble NRTRK = 2; // Коэффициент NRTRstring Symbols[]={"EURUSD","GBPUSD","USDCHF","USDJPY"};
CParabolicStop *SARTrailing[];
CNRTRStop *NRTRTrailing[];
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
ArrayResize(SARTrailing,ArraySize(Symbols)); // изменение размера в соответствии с количеством используемых символовArrayResize(NRTRTrailing,ArraySize(Symbols)); // изменение размера в соответствии с количеством используемых символов for(int i=0;i<ArraySize(Symbols);i++)
{ // для всех символов
SARTrailing[i]=new CParabolicStop(); // создание экземпляра класса CParabolicStop
SARTrailing[i].Init(Symbols[i],PERIOD_CURRENT,false,true,true,5,15+i*17,Silver,Blue); // инициализация экземпляра класса CParabolicStop if(!SARTrailing[i].SetParameters(SARStep,SARMaximum))
{ // установка параметров экземпляра класса CParabolicStop Alert("trailing error");
return(-1);
}
SARTrailing[i].StartTimer(); // запуск таймера//----
NRTRTrailing[i]=new CNRTRStop(); // создание экземпляра класса CNRTRStop
NRTRTrailing[i].Init(Symbols[i],PERIOD_CURRENT,false,true,true,127,15+i*17,Silver,Blue); // инициализация экземпляра класса CNRTRStop if(!NRTRTrailing[i].SetParameters(NRTRPeriod,NRTRK))
{ // установка параметров экземпляра класса CNRTRcStop Alert("trailing error");
return(-1);
}
NRTRTrailing[i].StartTimer(); // запуск таймера
}
return(0);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
for(int i=0;i<ArraySize(Symbols);i++)
{
SARTrailing[i].Deinit();
NRTRTrailing[i].Deinit();
delete(SARTrailing[i]);
delete(NRTRTrailing[i]);
}
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
for(int i=0;i<ArraySize(Symbols);i++)
{
SARTrailing[i].DoStoploss();
NRTRTrailing[i].DoStoploss();
}
}
//+------------------------------------------------------------------+voidOnTimer()
{
for(int i=0;i<ArraySize(Symbols);i++)
{
SARTrailing[i].Refresh();
NRTRTrailing[i].Refresh();
}
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnChartEvent(constint id,
constlong &lparam,
constdouble &dparam,
conststring &sparam
)
{
for(int i=0;i<ArraySize(Symbols);i++)
{
SARTrailing[i].EventHandle(id,lparam,dparam,sparam);
NRTRTrailing[i].EventHandle(id,lparam,dparam,sparam);
}
}
//+------------------------------------------------------------------+
And if you're not hard, please specify where it's written about this asterisk as a pointer * in the documentation. I saw it once, but I've already looked through a textbook and can't find it((((
Основное правило трейдера - дай прибыли расти, обрезай убытки! В статье рассматривается один из основных технических приемов, позволяющий следовать этому правилу - перемещение уровня защитной остановки (уровня Stoploss) вслед за растущей прибылью позиции, другими словами - скользящий стоп или трейлинг стоп (trailingstop). Приводится пошаговая процедура создания класса для трейлинг стопа на индикаторах SAR и NRTR, который каждый желающий сможет за 5 минут встроить в своего эксперта или использовать независимо для управления позициями на своем счете.
Hello, is it possible and how to create an algorithm for opening and closing a deal without using any indicators?
For example, take two lines, one trend line up and the second is also down, put them on top of each other, there is a point of intersection between the two lines, let's assume it is at 15-30 in time, then how to make the order automatically opened at the same time to start in any direction, how to make the algorithm will find these points and open a position? I would like clarification and your opinions.
Hi there!!! A question like this? I need to collect into arrays, the indicator handles on different timeframes, but it turns out that
Fractal=iFractals(Symbol(),tik);
cannot be done that way( Strange, why can prime numbers be used in this parameter, but not a variable with a numeric constant?
voidOnTick()
{
for(int tik =1; tik <= 6; tik++)
{
Fractal=iFractals(Symbol(),tik); // Вот эта tik переменная вызывает ошибку при компиляции
switch(tik)
{
case1:
CopyBuffer(Fractal,0,TimeCurrent(),Bars(Symbol(),PERIOD_W1),FractalUP_W1); // заполнение масива FractalUp[] верхними фракталами на дневном графикеCopyBuffer(Fractal,1,TimeCurrent(),Bars(Symbol(),PERIOD_W1),FractalDown_W1); // заполнение масива FractalUp[] нижними фракталами на дневном графике//--- индексация как в таймсерияхArraySetAsSeries(FractalUP_W1,true); //Заполнение массива FractalUp[],FractalDown, нулевым баром в первом окне массива и далее по порядку убывания от нулевого в тайм-серииArraySetAsSeries(FractalDown_W1,true);//Второй параметр -true- функции ArraySetAsSeries Устанавливает флаг индексации как в таймсериях.
;
break;
case2:
CopyBuffer(Fractal,0,TimeCurrent(),Bars(Symbol(),PERIOD_D1),FractalUP_D1); // заполнение масива FractalUp[] верхними фракталами на дневном графикеCopyBuffer(Fractal,1,TimeCurrent(),Bars(Symbol(),PERIOD_D1),FractalDown_D1); // заполнение масива FractalUp[] нижними фракталами на дневном графике//--- индексация как в таймсерияхArraySetAsSeries(FractalUP_D1,true); //Заполнение массива FractalUp[],FractalDown, нулевым баром в первом окне массива и далее по порядку убывания от нулевого в тайм-серииArraySetAsSeries(FractalDown_D1,true);//Второй параметр -true- функции ArraySetAsSeries Устанавливает флаг индексации как в таймсериях.
;
break;
case3:
CopyBuffer(Fractal,0,TimeCurrent(),Bars(Symbol(),PERIOD_H4),FractalUP_H4); // заполнение масива FractalUp[] верхними фракталами на дневном графикеCopyBuffer(Fractal,1,TimeCurrent(),Bars(Symbol(),PERIOD_H4),FractalDown_H4); // заполнение масива FractalUp[] нижними фракталами на дневном графике//--- индексация как в таймсерияхArraySetAsSeries(FractalUP_H4,true); //Заполнение массива FractalUp[],FractalDown, нулевым баром в первом окне массива и далее по порядку убывания от нулевого в тайм-серииArraySetAsSeries(FractalDown_H4,true);//Второй параметр -true- функции ArraySetAsSeries Устанавливает флаг индексации как в таймсериях.
;
break;
case4:
CopyBuffer(Fractal,0,TimeCurrent(),Bars(Symbol(),PERIOD_H1),FractalUP_H1); // заполнение масива FractalUp[] верхними фракталами на дневном графикеCopyBuffer(Fractal,1,TimeCurrent(),Bars(Symbol(),PERIOD_H1),FractalDown_H1); // заполнение масива FractalUp[] нижними фракталами на дневном графике//--- индексация как в таймсерияхArraySetAsSeries(FractalUP_H1,true); //Заполнение массива FractalUp[],FractalDown, нулевым баром в первом окне массива и далее по порядку убывания от нулевого в тайм-серииArraySetAsSeries(FractalDown_H1,true);//Второй параметр -true- функции ArraySetAsSeries Устанавливает флаг индексации как в таймсериях.
;
break;
case5:
CopyBuffer(Fractal,0,TimeCurrent(),Bars(Symbol(),PERIOD_M30),FractalUP_30); // заполнение масива FractalUp[] верхними фракталами на дневном графикеCopyBuffer(Fractal,1,TimeCurrent(),Bars(Symbol(),PERIOD_M30),FractalDown_30); // заполнение масива FractalUp[] нижними фракталами на дневном графике//--- индексация как в таймсерияхArraySetAsSeries(FractalUP_30,true); //Заполнение массива FractalUp[],FractalDown, нулевым баром в первом окне массива и далее по порядку убывания от нулевого в тайм-серииArraySetAsSeries(FractalDown_30,true);//Второй параметр -true- функции ArraySetAsSeries Устанавливает флаг индексации как в таймсериях.
;
break;
case6:
CopyBuffer(Fractal,0,TimeCurrent(),Bars(Symbol(),PERIOD_M15),FractalUP_15); // заполнение масива FractalUp[] верхними фракталами на дневном графикеCopyBuffer(Fractal,1,TimeCurrent(),Bars(Symbol(),PERIOD_M15),FractalDown_15); // заполнение масива FractalUp[] нижними фракталами на дневном графике//--- индексация как в таймсерияхArraySetAsSeries(FractalUP_15,true); //Заполнение массива FractalUp[],FractalDown, нулевым баром в первом окне массива и далее по порядку убывания от нулевого в тайм-серииArraySetAsSeries(FractalDown_15,true);//Второй параметр -true- функции ArraySetAsSeries Устанавливает флаг индексации как в таймсериях.
;
break;
}
}
Kira27: Hi!!! I have a question. I need to collect indicator handlers on different timeframes into arrays, but it turns out that can't do that( It's strange, why can I use prime numbers in this parameter, but not a variable with a numeric constant?
Kira27: I need to collect the indicator handles on different timeframes into arrays, but it turns out that cannot be done that way( I wonder why you can use prime numbers in this parameter, but not variables with numeric constants?
Indicator handle in MQL5 MUST BE CREATED ONE TIME!!! And it must be done in OnInit()!!!
But how do I get this value for another currency pair?
Can you tell me please?
What _Digits is I understand.
How to get it for another currency pair?
Please, help me.
SYMBOL_DIGITS
Number of digits after the decimal point
int
MqlTradeRequest mrequest ???
Maybe there is a function in MQL5? I want to understand why I get this message 2021.02.08 21:29:20.876 my_first_ea_sartrailing (BRN,M5) Alert: Request to place Sell order failed - error code:4756
Hi!!! Can you tell me how to log the completed structure
MqlTradeRequest mrequest ???
Maybe there is a function in MQL5? I want to understand why I get this message 2021.02.08 21:29:20.876 my_first_ea_sartrailing (BRN,M5) Alert: Request to place Sell order failed - error code:4756
https://www.mql5.com/ru/forum/327894
And here is the transcript: herehow to programmatically remove the Alert dialog box from the window?
And if you're not hard, please specify where it's written about this asterisk as a pointer * in the documentation. I saw it once, but I've already looked through a textbook and can't find it((((
Hello, is it possible and how to create an algorithm for opening and closing a deal without using any indicators?
For example, take two lines, one trend line up and the second is also down, put them on top of each other, there is a point of intersection between the two lines, let's assume it is at 15-30 in time, then how to make the order automatically opened at the same time to start in any direction, how to make the algorithm will find these points and open a position? I would like clarification and your opinions.
Can we create an EA based on such T3?cannot be done that way( Strange, why can prime numbers be used in this parameter, but not a variable with a numeric constant?
Hi!!! I have a question. I need to collect indicator handlers on different timeframes into arrays, but it turns out that
can't do that( It's strange, why can I use prime numbers in this parameter, but not a variable with a numeric constant?
Because there has to be a timeframe
Identifier
Description
PERIOD_CURRENT
Current period
PERIOD_M1
1 minute
PERIOD_M2
2 minutes
PERIOD_M3
3 minutes
PERIOD_M4
4 minutes
PERIOD_M5
5 minutes
PERIOD_M6
6 minutes
PERIOD_M10
10 minutes
PERIOD_M12
12 minutes
PERIOD_M15
15 minutes
PERIOD_M20
20 minutes
PERIOD_M30
30 minutes
PERIOD_H1
1 hour
PERIOD_H2
2 hours
PERIOD_H3
3 hours
PERIOD_H4
4 hours
PERIOD_H6
6 hours
PERIOD_H8
8 hours
PERIOD_H12
12 hours
PERIOD_D1
1 day
PERIOD_W1
1 week
PERIOD_MN1
1 month
I need to collect the indicator handles on different timeframes into arrays, but it turns out that
cannot be done that way( I wonder why you can use prime numbers in this parameter, but not variables with numeric constants?
Indicator handle in MQL5 MUST BE CREATED ONE TIME!!! And it must be done in OnInit()!!!