You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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()?