Is this a bug or is it me?

 

I have a custom indicator that places an arrow at the close price when a direction change is imminent. When the indicator is run in the visual mode of the back tester the arrow will appear and go up and down with the close price until the candle closes at which point the arrow remains at the close price. In my EA I wanted to trade the arrow but it would only trade if I ask the custom indicator the state of the arrow at a shift of one so I put some diagnostic comments and have established that the arrow buffer only gets set when the candle is closed and not on the current open candle even though the arrow is displayed on the screen. How can the arrow be displayed and move with the current close price when the arrow buffer contains the EMPTY value? Here are the displays for a shift of 0 and 1.


Any help is appreciated.



 

Is your "shift" on the iCustom 0 or 1? I guess yours is 1.

0=the current running candle

1=the last closed candle

2=the previous of the last closed candle, and so on


Hope this helps

 
The top graph is a shift of zero and you can see there is an arrow and yet the value for arrow I received from the indicator is the empty value of 2147483647. The bottom graph is a shift of 1 and the arrow value is the close price of 1.5057 where the arrow is drawn on the last closed candle. How can the top graph have an arrow at the close price and yet the indicator does not have a value for it.
 
Anybody have any ideas on this? I don't see how the arrow buffer can be empty when an arrow is displayed. This means buffer reading does not return the contents of the required buffer so it has to be a bug.
 
Ruptor:
Anybody have any ideas on this? I don't see how the arrow buffer can be empty when an arrow is displayed. This means buffer reading does not return the contents of the required buffer so it has to be a bug.


Hi Ruptor!

Uummmm...  I probably wouldn't have time to look at code anyway, but without the actual code involved showing, one guess that could explain your described symptoms would be this...

In MQL4 indicators can create and control objects, which I put to use a lot in my own indicator designs...  The object can receive it's position (x y coordinates) without that data going into, or through the index buffers.  So, the object can exist under indicator control, but there is no direct relationship to the indicator's index buffer data.  I don't know that this is the case, but it is possible, and could explain why you see arrows, but no corresponding index buffer data. If this is the case then this would not be a bug.

Just thought I would throw this out for you to consider since you are asking for ideas.

Good luck!

 
Right click on the chart and show objects. If the indicator is using objects you'll see them listed
 

Hi Guys

I wrote the indicator and didn't knowingly use objects so I slapped it on a chart and right clicked like you suggested but there was no object list selection available on the menu so I am assuming there are no objects. I did the same on a visual backtest chart and that gave a list of objects of arrows but after further examination the arrow objects were from the system buy and sell arrows not my indicator. I have done a test indicator that only has one buffer for arrows and that returns the correct value so it is something peculiar to my indicator and perhaps where or when the EA queries the contents of the arrow buffer.

 

you can paste here your comment code, maybe we can suggest you a better one.

 

Hi Guys

It looks like it is a timing issue but I don't completely understand it at the moment. In the EA I test for a trading condition at the first tick of a new candle using the following code.

      if (timeold!=Time[0]){
         timeold=Time[0];
            sadoprv=sado;
            sadcprv=sadc;
            trdseq=iCustom(Symbol(),0,"iFatSdky",BarsUsed,nd,5,0);
            sadc=iCustom(Symbol(),0,"iFatSdky",BarsUsed,nd,3,0);
            tstcnt++;
            Comment("testcount= ",tstcnt,"  trdseq= ",trdseq,"  arrow= ",sadc);


If I comment out the first line the EA trades many times and arrow is set to close price many times. I would have thought an arrow would have still been picked up by trading on the first tick of a new candle as intended. Maybe there wouldn't be as many trades but there should be some trades in a month of back testing. It is difficult to see that an arrow would never occur on the first tick of a new candle.

Reason: