Using iCustom in Strategy Tester

To add comments, please log in or register
Bostock58
115
Bostock58  

I have written an indicator that puts an arrow above a pinbar when detected, if the next candle moves ahead 4 points it puts a horizontal arrow on [i] pointing at the entry position on the next candle. It works well and puts the arrow

permanently at the +4 points level on the chart.

       
 

           if(Close[i]>(Open[i+1]+Close[i+1])*0.5)
               {
               upArrow[i]=High[i]+2;
               if(Close[i-1]-Close[i]>=4)
                  {double upenter=Close[i];
                   bullentry[i]=(upenter+4);}
                 } 


The EA calls the 'bullentry' arrow using iCustom, however when I run it in the strategy tester it ignores the arrow but opens a trade when the candle closes!

        total=OrdersTotal();
        static datetime candletime = 0;
        if(candletime != Time[0])
        if(Market>0)
        {
         //Did it make an up arrow on candle 1?
         double bullentry = iCustom(NULL,0,"CombinedCandle2",2,1);
         if(bullentry != EMPTY_VALUE)
            if(total<1)
               EnterTrade(OP_BUY);

Any suggestions on how to get an entry when the arrow is produced?

Bostock58
115
Bostock58  
Anyone? Anything?
Keith Watford
Moderator
14561
Keith Watford  
               if(Close[i-1]-Close[i]>=4)

Assuming Set as Series is true, it is never a good idea to use i-1 as you are using future values.

double bullentry = iCustom(NULL,0,"CombinedCandle2",2,1);

You are checking the most recent closed bar, so you won't get a value until the bar closes

Bostock58
115
Bostock58  
      if(Close[i]>(Open[i+1]+Close[i+1])*0.5)
               {
               upArrow[i]=High[i]+2;

Since the indication is on [i] the entry is on the next candle, I have not found any successful way look at the next candle other than [i-1] which is far from ideal as mql4 seems to then fix [i] rather than move it forward with every new candle. I was originally using [i-2] as well meaning nothing happened until the second candle closed regardless of [i-1] being true.

I have not been able to find any exact definition of the shift value in iCustom so didnt know if 1 or 0 gave the current candle as I have tried both or what other values could be used.

I had assumed iCustom was looking for an arrow to form in the Indicator,

 upArrow[i]=High[i]+2;

Otherwise I cant see the point of using an Indicator at all and iCustom would have no use, you could just ask the EA to look at candle [1]?!

So if its triggered by an arrow in buffer 2 why does it need to wait to the close of the candle when the arrow has already formed?

Keith Watford
Moderator
14561
Keith Watford  
Bostock58:

I have not been able to find any exact definition of the shift value in iCustom so didnt know if 1 or 0 gave the current candle as I have tried both or what other values could be used. 

in iCustom(), shift 0 is the current (open) candle. Shift 1 is the previous (closed candle) etc.

Bostock58
115
Bostock58  

iCustom was set to 1 the last completed candle, the arrow indicates on the last completed candle but still it waits until the current candle completes?!

If its ignoring the indicator buffer 'not being empty' then what is the point of iCustom??

Keith Watford
Moderator
14561
Keith Watford  
Bostock58:

iCustom was set to 1 the last completed candle, the arrow indicates on the last completed candle but still it waits until the current candle completes?!

If its ignoring the indicator buffer 'not being empty' then what is the point of iCustom??

Which bar is the indicator buffer 'not being empty'  ?

Bostock58
115
Bostock58  
 {double upenter=Close[i];
                   bullentry[i]=(upenter+4);}

The arrow buffer 'bullentry' is placed on candle [i] at a position of the Close[i] + 4 points, the arrow correctly appears on the chart at the right position and stays there on a live chart and the strategy tester.

However because I am using [i-1] in the 'if' statement above it, means the candle currently forming is [i-1].

So using a shift value of 1 (the last completed candle) would seem correct, however it waits until [i-1] has completed for the EA to open a trade.

All of which seems totally contradictory to, the indicator buffer 'not being empty'...?

Bostock58
115
Bostock58  
No one knows how iCustom works?!
Keith Watford
Moderator
14561
Keith Watford  
Bostock58:
No one knows how iCustom works?!

We know the way that iCustom works.

I for one, do not understand what you are asking.

Why are you looking at index [i-1]? As I have already told you, you should never include [i-1] unless you are not using Series.

Bostock58
115
Bostock58  

To be fair I have stated in almost every post that the problem is iCustom is ignoring the Arrow Buffer becoming 'not empty' in the Indicator and waiting till the candle has completed to open a trade in the EA.

You said previously "Assuming Set as Series is true, it is never a good idea to use i-1 as you are using future values." Unfortunately I dont know what you mean by 'Set as Series is true'.

But I also said I would rather not be using [i-1] (I actually use [i-2] as well and have to use 2 separate Indicators to make it work) However I have not found any other way to successfully look at the next candle (how this can be so difficult is bizarre). I have researched all over the net and found many arguments and variations of an 'OnNextCandle' function and reasons why each option doesnt work but nothing that does!! I have tried all of them and the result is usually nothing on the chart at all.

If you have a working method for something 'as simple' as looking at the next candle I would be VERY interested how.

However I think that would still leave the problem of iCustom ignoring the Arrow Buffer.

12
To add comments, please log in or register