Why does isCrossing() not return 2??? The isCrossing() itself has a second if entry, but then there is no if entry in OnTick() when isCrossing() == 2. What a load of nonsense...
Why does isCrossing() not return 2??? The isCrossing() itself has a second if entry, but then there is no if entry in OnTick() when isCrossing() == 2. What a load of nonsense...
For some reason I don't think it returns 1 either.
This condition
if(g_barTime < iTime(NULL,g_timeFrame,0)// и дальше
Tells you that a new bar has been opened. On the first tick of the bar open == high == low == close and == Bid - hence the condition
&& high > ma && Bid <= ma)
or
&& low < ma && Bid >= ma)
cannot be fulfilled...
There was a question today about the condition if(i != i) These conditions are approximately the same.
Further, even if everything is equal, it is only on the first tick.
It works like this
//--- input parametersinputint g_maPeriod = 14;
inputint g_maShift = 1;
inputENUM_APPLIED_PRICE g_maPrice = PRICE_CLOSE; //Applied priceinputENUM_MA_METHOD g_maMethod = MODE_SMA; //Method MainputENUM_TIMEFRAMES g_timeFrame = PERIOD_CURRENT; //Timeframe for calculatedatetime g_barTime=0;
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---if(g_barTime != iTime(NULL,g_timeFrame,0))
{
if(isCrossing()==1)
{
Print("enter to '1. if (isCrossing)'"); g_barTime = iTime(NULL,g_timeFrame,0);
}
if(isCrossing()==2)
{
Print("enter to '2. if (isCrossing)'"); g_barTime = iTime(NULL,g_timeFrame,0);
}
}
}
//+------------------------------------------------------------------+int isCrossing()
{
int res=0;
double low = iLow(Symbol(), g_timeFrame, 1);
double high = iHigh(Symbol(), g_timeFrame, 1);
double ma = iMA(_Symbol, g_timeFrame, g_maPeriod, g_maShift, g_maMethod, g_maPrice, 0);
if(high > ma && Bid <= ma) res=1;
if(low < ma && Bid >= ma) res=2;
return (res);
}
//+------------------------------------------------------------------+
2021.08.2509:24:56.6292021.08.2023:50:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.6242021.08.2023:45:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5922021.08.2021:35:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5822021.08.2021:05:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.5662021.08.2020:20:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.5542021.08.2018:50:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5532021.08.2018:45:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5532021.08.2018:40:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.6292021.08.2023:50:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.6242021.08.2023:45:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5922021.08.2021:35:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5822021.08.2021:05:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.5662021.08.2020:20:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
2021.08.2509:24:56.5542021.08.2018:50:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5532021.08.2018:45:00 Nerd Trader EURUSD,M5: enter to '2. if (isCrossing)'
2021.08.2509:24:56.5532021.08.2018:40:00 Nerd Trader EURUSD,M5: enter to '1. if (isCrossing)'
Saw now that you've added a log. Here you have duplicate messages too :)
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.
Both conditions fit...so you get the first result
Both conditions fit...so you get the first result
For some reason I don't think it returns 1 either.
This condition
Tells you that a new bar has been opened. On the first tick of the bar open == high == low == close and == Bid - hence the condition
or
cannot be fulfilled...There was a question today about the condition if(i != i) These conditions are approximately the same.
P.S.
with the isCrossing() function left everything as it is.
For some reason I don't think it returns 1 either.
This condition
tells about the opening of a new bar. On the first tick of the bar open == high == low == close and == Bid - hence, the condition
or
cannot be fulfilled...There was a question today about the condition if(i != i) These conditions are about the same.
"1" returns, did code debugging in MetaEditor.
Further, even if everything is equal, it's only on the first tick.
"1" returns, did code debugging in MetaEditor.
Further, even if everything is equal, it's only on the first tick.
Well, yes, I was wrong. The new bar will be only after the whole condition is fulfilled.
Try to replace high and low by open. Maybe it won't affect the strategy too much.
"1" returns, did code debugging in MetaEditor.
Further, even if everything is equal, it is only on the first tick.
It works like this
It works like this.
I did this and it all works, only messages from isCrossing() are duplicated, because the f-e is called twice for one tick.
So I left it as it was, only now everything from isCrossing() is returned to variable. Nothing is duplicated and everything works. Thanks all :)
can you please explain the difference between the functions?
for (int j = OrdersHistoryTotal()-1; j >= 0; j--)
{
if(OrderSelect(j, SELECT_BY_POS,MODE_HISTORY))
и
int i=OrdersHistoryTotal();
for(int pos=0; pos<i; pos++)
{
if(OrderSelect(pos, SELECT_BY_POS,MODE_HISTORY))