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

 
Snajper007 #:

This code shows the signal on the 10th candle. I need to check the signal on each candle from 1 to N.

Change the order of the search.

You are searching from the depth of time to the present time and therefore find the "oldest signal".

Judging by iCustom - you have 4 and so the numbering.

the loop must be from 0 (more likely 1-2) and up to N

for(int i=0;i<n;i++)

 
Snajper007 #:
int n=10;
   datetime bar_sig_buy, bar_sig_sell;

   for(int i=n;i>=0;i--)
     {
     // для покупок
   double a1 = iCustom(NULL, 0, "FL11", 4, i);
   // для продаж 
   double a2 = iCustom(NULL, 0, "FL11", 5, i);


      if(a1 > 0)
         bar_sig_buy=Time[i];
         
      if(a2 > 0)
        bar_sig_sell = Time[i];
     Comment("bar_sig_sell = " + DoubleToString(bar_sig_sell)+ "\n" +
     "bar_sig_buy = " + DoubleToString(bar_sig_buy));

     }
 
As far as I remember the FL11 indicator is crooked and you can't use it properly. Redrawing... Cycle should lead from 0 to the left and interrupt if a signal is found... Or, reset the time of the signal in the body of the cycle and print the result of each bar. But you will not learn anything with this indicator, get a normal one.
 
MakarFX #:
int n=10;
   datetime bar_sig_buy, bar_sig_sell;

   for(int i=n;i>=0;i--)
     {
     // для покупок
   double a1 = iCustom(NULL, 0, "FL11", 4, i);
   // для продаж 
   double a2 = iCustom(NULL, 0, "FL11", 5, i);


      if(a1 > 0)
         bar_sig_buy=Time[i];
         
      if(a2 > 0)
        bar_sig_sell = Time[i];
     Comment("bar_sig_sell = " + DoubleToString(bar_sig_sell)+ "\n" +
     "bar_sig_buy = " + DoubleToString(bar_sig_buy));

     }
Nothing has changed. The signal is still showing on the 10th candle
 
Snajper007 #:
Nothing has changed. The signal is still showing on the 10th candle
2021.11.08 18:44:44.620 2021.10.15 17:10:00  BAG GBPUSD,H1: 0/sell: 2021.10.15 17:00:00
2021.11.08 18:44:44.571 2021.10.15 17:07:30  BAG GBPUSD,H1: 0/sell: 2021.10.15 17:00:00
2021.11.08 18:44:44.530 2021.10.15 17:05:00  BAG GBPUSD,H1: 3/sell: 2021.10.15 14:00:00
2021.11.08 18:44:44.480 2021.10.15 17:02:30  BAG GBPUSD,H1: 3/sell: 2021.10.15 14:00:00
2021.11.08 18:44:44.432 2021.10.15 17:00:00  BAG GBPUSD,H1: 3/sell: 2021.10.15 14:00:00
2021.11.08 18:44:44.385 2021.10.15 16:59:59  BAG GBPUSD,H1: 2/sell: 2021.10.15 14:00:00
2021.11.08 18:44:44.339 2021.10.15 16:57:30  BAG GBPUSD,H1: 2/sell: 2021.10.15 14:00:00
 
Snajper007 #:
Nothing has changed. The signal is still shown on the 10th candle

Here is the function to analyse this signal of this indicator from my old archive, adjust it for your own needs...

Returns the last signal. 1 - upper sun, 0 - lower sun. -1 - no signal/error.

int gsun(ENUM_TIMEFRAMES tf)
{
double up=0.0,dw=0.0;
for(int i=1;i<iBars(Symbol(),tf);i++)
  {
  up=iCustom(Symbol(),tf,"FL11",Period1,Period2,Period3,Deviat1,Deviat2,Deviat3,5,i);
  dw=iCustom(Symbol(),tf,"FL11",Period1,Period2,Period3,Deviat1,Deviat2,Deviat3,4,i);
  if(up!=0.0&&up!=EMPTY_VALUE)return(1);
  if(dw!=0.0&&dw!=EMPTY_VALUE)return(0);
  }
return(-1);
}
//---
 

MakarFX

Thank you! It's working!

 
Nikolay Ivanov #:
As far as I remember the FL11 indicator is crooked and you can't use it properly. Redrawing... Cycle should lead from 0 to the left and interrupt if a signal is found... Or, reset the time of the signal in the body of the cycle and print the result of each bar. But you will not learn anything with this indicator.
What is a normal indicator?
 
Snajper007 #:


The picture should be inserted using the button Image or attached using the button Attach file

 
Snajper007 #:
What is the correct indicator?

Any one that doesn't overdraw more than the logic, usually 0 bar, for fractals 2.

I am judging in terms of correct operation.

Reason: