[EA] Issue with defining high and low of bar where the signal appears - page 2

 
RaptorUK:
you are using iCustom with bar 0,  does the Indicator re-paint for bar 0 ?  does the Indicator need a few complete bars following the indicated bar ?

I think you have probably right. The value is generated in couples candles ahead so if I understand correctly thats the problem.

I do not get it. IN EA I have information that my idicator is loaded succesfully so I believe that it calculates all values as normal indicator and later EA analyzes it . AM I right? If not what should be changed? On which aspect should I take a look?
      if (Close[i-f-Shift]>High[i-Shift])
         {
          SIGNAL[i-f-Shift-1]= 1.0;
         }
      if (Close[i-f-Shift]<Low[i-Shift])
         {
          SIGNAL[i-f-Shift-1]= -1.0;
         } 

Thanks clerin6 for link but I do not see answer for my issues there. 

In EA i do not use anymore defined time but 0 which indicates the current  timeframe.

     double high=iHigh(Symbol(),0,0);
      double low=iLow(Symbol(),0,0);
 
RaptorUK:

Can you copy and paste the contradiction ?  I don't seem to see it . . .

Specifically with reference to getting the high and low:

... if we test an Expert Advisor on the timeframe EURUSD M15, we can see the values of the indicators for EURUSD H1 or EURUSD M5.

We can also see the maximal and minimal prices of the current zero bar on any available timeframe EURUSD.

That would seem to suggest that at least iHigh and iLow would work. Doesn't it? Am I being dense?

The first article states:

Zero bar of another timeframe for the same symbol under test is modeled approximately

Open = correct Open, Close = correct Close, Low = min (Open,Close), High = max (Open,Close), Volume = final Volume (false)

If this really is still the case then clearly trying to get the high and low would not work correctly. But if the new(er) article is speaking about some implicit update made to the tester later, then I just wondered whether it is perhaps then possible to at least get high and low for zero bar on another time frame.

Then the article goes on to claim:

The receipt of each new tick changes the information about the zero bar condition on each timeframe

and:

All requested timeframes (and not only prices, but also volumes) are correctly modelled. The tester sees the synchronous price progress on each timeframe, like in real life

Isn't that a direct contradiction of the first article? Especially the bit about volume?

Both articles seem to be authored by MetaQuotes.

I haven't actually tested it. I'm just going from the articles. Generally I'm inclined to believe WHRoeder over the articles anyway! I just wondered about the seeming contradiction and whether that affected the problem in this case.

I am not intending to hijack the thread. I can see that this is no longer relevant to your problem. Sorry.

 
clerin6: I haven't actually tested it. I'm just going from the articles. Generally I'm inclined to believe WHRoeder over the articles anyway! 
Nice to be believed but I hadn't tested it either but was quoting the article. So I tested it in a EA:
int     start(){                        
Print("My time frame    "," Open=",PriceToStr(Open[0]),"  High=",PriceToStr(High[0]),"   Low=",PriceToStr(Low[0]),
  "  Close=",PriceToStr(Close[0]),"  Volume=",Volume[0],"  Bid=",PriceToStr(Bid));
Print("30 minute frame "," Open=",PriceToStr(iOpen(NULL,PERIOD_M30,0)),"  High=",PriceToStr(iHigh(NULL,PERIOD_M30,0)),
  "   Low=",PriceToStr(iLow(NULL,PERIOD_M30,0)),"  Close=",PriceToStr(iClose(NULL,PERIOD_M30,0)),
  "  Volume=",iVolume(NULL,PERIOD_M30,0),"  Bid=",PriceToStr(Bid));
Print("1 hour frame      "," Open=",PriceToStr(iOpen(NULL,PERIOD_H1,0)),"  High=",PriceToStr(iHigh(NULL,PERIOD_H1,0)),
  "   Low=",PriceToStr(iLow(NULL,PERIOD_H1,0)),"  Close=",PriceToStr(iClose(NULL,PERIOD_H1,0)),
  "  Volume=",iVolume(NULL,PERIOD_H1,0),"  Bid=",PriceToStr(Bid));
Print("4 hour frame      "," Open=",PriceToStr(iOpen(NULL,PERIOD_H4,0)),"  High=",PriceToStr(iHigh(NULL,PERIOD_H4,0)),
  "   Low=",PriceToStr(iLow(NULL,PERIOD_H4,0)),"  Close=",PriceToStr(iClose(NULL,PERIOD_H4,0)),
  "  Volume=",iVolume(NULL,PERIOD_H4,0),"  Bid=",PriceToStr(Bid));
return(0);
EURUSD,Daily: 4 hour frame     Open=1.43344  High=1.43344   Low=1.42595  Close=1.42627  Volume=1402  Bid=1.42627
EURUSD,Daily: 1 hour frame     Open=1.43344  High=1.43344   Low=1.42595  Close=1.42627  Volume=1402  Bid=1.42627
EURUSD,Daily: 30 minute frame  Open=1.42659  High=1.42691   Low=1.42595  Close=1.42627  Volume=546   Bid=1.42627
EURUSD,Daily: My time frame    Open=1.43344  High=1.43344   Low=1.42595  Close=1.42627  Volume=1402  Bid=1.42627

I tried both Daily looking at smaller TFs and 5 minute looking at larger. Bar 0 was fine in Build 445. I stand corrected.
 
Great, thanks for posting the runthrough :-) Good to know for future reference!
 

Thanks for it. Anyway lets back to the topic.... I will briefly repeat the issue:

There is an EA where trading decision is made based on below code:

 if (SIGNAL == 1.0)  
     {
      Print ("Opn_B=" , SIGNAL );                     
      Opn_B=true;                                
                                    
     }
   if (SIGNAL == -1.0)        
     {
      Print ("Opn_B=" , SIGNAL );                                     
      Opn_S=true;                                                            
     }

EA exports value from indicator

SIGNAL = iCustom(NULL,0,"INDICATOR_FOR_TRADING",Avg,Shift,6,0);

Indicator looks following:

 if (MA[i]>MA2[i] && iWaitFor == PLOTDOWN)
    {
      iWaitFor = PLOTUP;
      CROSS[i-Shift] = 0.0;
      f=1;
      while (High[i-Shift]>Close[i-f-Shift] && Close[i-f-Shift]>Low[i-Shift])
      {
      f++;
      }

      if (Close[i-f-Shift]>High[i-Shift])
         {
          SIGNAL[i-f-Shift-1]= 1.0;
         }
      if (Close[i-f-Shift]<Low[i-Shift])
         {
          SIGNAL[i-f-Shift-1]= -1.0;
         } 
    }

When EA starts Indicator is loaded successfully but it does not receive back any signal.  I believe that indicator calculates all values as normal indicator and later EA analyzes it . AM I right? If not what should be changed? On which aspect should I take a look?

I think that Raptor

"you are using iCustom with bar 0,  does the Indicator re-paint for bar 0 ?  does the Indicator need a few complete bars following the indicated bar ?"

has right. I wonder how the EA actually works. If the indicator is loaded first then based on below condition 

 if (SIGNAL == 1.0) 

if first value reaches 1.0 from left side buy signal is activated and the rest code is executed. After that the next signal is searched..... If my logic is wrong please correct me...


Thanks for any help.

Reason: