and what does the following command print("Number of lots : ",Lots); ?
#property link"" #property version"1.00" #property strict //--- input parameters inputint Percent=50; inputint Fast_EMA_Period=12; inputint Slow_EMA_Period=25; inputint Signal_Period=9; inputdouble Step_PSAR=0.02; inputdouble Maximum_PSAR=0.2; inputint MAGICNUMBER=413; staticdatetime New_Time;// Время текущего бара double Margin_Percent; //Используемые средства для открытия ордеров double Lots;//Определение общего количества лотов double Lots_Volume; double MacdCurrent;//Параметры MACD основной линии текущего бара double MacdPrevious1;//Параметры MACD основной линии предыдущего бара double MacdPrevious2;//Параметры MACD основной линии со смещением на 2 бара double StopLoss;//Параметры Трейлинг стоп по параметрам ParabolicSAR текущего бара double Previous_StopLoss;//Параметры СтопЛосс по параметрам ParabolicSAR предыдущего бара double CurrentPSAR;//Параметры СтопЛосс по параметрам ParabolicSAR предыдущего бара //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ voidOnTick() {
bool New_Bar=false; // Флаг нового бара int ticket,total,cnt; //--------------------------------------------------------------------------- New_Time=TimeCurrent(); if(Time[0]==New_Time) // Сравниваем время New_Bar=true; // Поймался новый бар elseif(New_Bar==false) // Если бар не новый..
The fifth line specifies Percent. The log prints: "Amount of lots: 90.0100000001". Maybe we should add NormalizeDouble()?
Michail_David: Please give an example with an explicit condition. If I understand correctly, there should be one condition in the loop for opening. Right?
Give a command to open an order at the beginning of the code, right after calculation of lot and make sure that the tester works properly. Then you can put everything back.
Renat Akhtyamov: Give a command to open an order at the beginning of the code, just after calculating the lot, and make sure the tester is working properly. Then you can put everything back in place.
Thank you. I found a mistake. I had return; after calculation of lots. That's why the lots didn't open
Michail_David: The fifth line specifies Percent. The log displays: "Number of lots 90.0100000001". Maybe we should add NormalizeDouble()?
Yes, you should. And not only lots, but all the other values which are passed to the server. Lots are also useful to check the minimum and maximum allowed in the account value, also on the step change, there were cases where the lot can be changed in increments of 0.03, so 90.01 will not work, at least overwritten.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I hope there is a value assigned to the Percent variable in OnInit()?
My Percent variable is user defined. OnInit() I've dropped it.
if Lots=0, nothing will be opened by the tester
Margin_Percent=AccountFreeMargin()*Percent/100;
Lots=Margin_Percent/MarketInfo(Symbol(),MODE_MARGINREQUIRED);
Lots_Volume=(MathFloor(Lots)+MarketInfo(Symbol(),MODE_LOTSTEP));
if(Lots>Lots_Volume){
Lots=Lots_Volume;
}
else if(Lots<Lots_Volume)
Lots=MathFloor(Lots);
Print("Количество лотов : ",Lots);
return;
And still, where in the code is set Percent
and what does the following command print("Lots : ",Lots); ?
Still, where in the code is Percent
and what does the following command print("Number of lots : ",Lots); ?
#property version "1.00"
#property strict
//--- input parameters
input int Percent=50;
input int Fast_EMA_Period=12;
input int Slow_EMA_Period=25;
input int Signal_Period=9;
input double Step_PSAR=0.02;
input double Maximum_PSAR=0.2;
input int MAGICNUMBER=413;
static datetime New_Time;// Время текущего бара
double Margin_Percent; //Используемые средства для открытия ордеров
double Lots;//Определение общего количества лотов
double Lots_Volume;
double MacdCurrent;//Параметры MACD основной линии текущего бара
double MacdPrevious1;//Параметры MACD основной линии предыдущего бара
double MacdPrevious2;//Параметры MACD основной линии со смещением на 2 бара
double StopLoss;//Параметры Трейлинг стоп по параметрам ParabolicSAR текущего бара
double Previous_StopLoss;//Параметры СтопЛосс по параметрам ParabolicSAR предыдущего бара
double CurrentPSAR;//Параметры СтопЛосс по параметрам ParabolicSAR предыдущего бара
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
bool New_Bar=false; // Флаг нового бара
int ticket,total,cnt;
//---------------------------------------------------------------------------
New_Time=TimeCurrent();
if(Time[0]==New_Time) // Сравниваем время
New_Bar=true; // Поймался новый бар
else if(New_Bar==false) // Если бар не новый..
In the fifth line Percent is set. The log shows: "The number of lots is 90.0100000001". Maybe we should add NormalizeDouble()?
There is nothing wrong with the lot.
Look for an error in the order opening logic.
In such cases, I usually set an explicit condition that will open the order
There is nothing wrong with the lot.
Look for an error in the order opening logic.
I usually in such cases set an explicit condition for the order to open
Please give an example with an explicit condition. If I understand correctly, there should be one condition in the loop for opening. Right?
Give a command to open an order at the beginning of the code, just after calculating the lot, and make sure the tester is working properly. Then you can put everything back in place.
The fifth line specifies Percent. The log displays: "Number of lots 90.0100000001". Maybe we should add NormalizeDouble()?