Array issue... i dont understand

 

Hello,

This is just some code to show on a graph sell dots. I want to track the history of buy/sell signals in an array, so by default i assign "0" to "SignalHisto".

When there is a signal, the value gets 1.


Now i want to use the data stored in the array. If i put in the last "if" statement : if (SignalHisto[i] == 1) then i will have two signal displayed on my graph ON THE SAME BAR, the one from the first "if" and the one from the second "if" (buffer 6 & 7). That is fine. But when i put as in the code below "if (SignalHisto[i+1] == 1), i would expect for have two signals displayed on the chart on TWO CONSECUTIVE BARS... But the buffer 6 signal isn't displayed.


Any reason ? With the i+1 it doesn't work but with "i" that is fine. With the "i+1" i only have Buffer 7 signal displayed.

Thanks
Greg

       SignalHisto[i] = 0;     
       
       if [SELL CONDITION]
            {
             ExtMapBuffer7[i] = High[i]+1*Point; //sell signal
             SignalHisto[i] = 1;
            }                                
 
       if (SignalHisto[i+1] == 1)
         {
            ExtMapBuffer6[i] = High[i]+2*Point; //sell signal     
           } 
 

I could be wrong here, I'm newer to programming EA's


Lets say you wanted to save the last 10 signals in your array. Set

int (or double if you have a decimal) SignalHisto[10];


Then realize that your index starts at zero so ...

SignalHisto[0] = "whatever your saving in the most recent index space";

SignalHisto[1] = "whatever your saving in the second most recent index space";

...

SignalHisto[9] = "whatever your saving in the 10th index space";

 
Greg_:

Hello,

This is just some code to show on a graph sell dots. I want to track the history of buy/sell signals in an array, so by default i assign "0" to "SignalHisto".

When there is a signal, the value gets 1.


Now i want to use the data stored in the array. If i put in the last "if" statement : if (SignalHisto[i] == 1) then i will have two signal displayed on my graph ON THE SAME BAR, the one from the first "if" and the one from the second "if" (buffer 6 & 7). That is fine. But when i put as in the code below "if (SignalHisto[i+1] == 1), i would expect for have two signals displayed on the chart on TWO CONSECUTIVE BARS... But the buffer 6 signal isn't displayed.


Any reason ? With the i+1 it doesn't work but with "i" that is fine. With the "i+1" i only have Buffer 7 signal displayed.

Thanks
Greg

Does your loop count up or down ?
 
So close together you can't see them.
ExtMapBuffer7[i] = High[i]+1*Point; //sell signal
ExtMapBuffer6[i] = High[i]+2*Point; //sell signal     
Try a minimum of 5 pips difference
ExtMapBuffer7[i] = High[i]+1*Point; //sell signal
ExtMapBuffer6[i] = High[i]+50*Point; //sell signal     
Adjust for 4/5 digit brokers
 

Thanks for answers, it's on DAX, so 1pt is enough to see it :)

The loop go forward i++

In fact the code works with "if (SignalHisto[i-1] == 1)" (so minus 1). It will give the signal on the bar before my sell condition.

It works "
if (SignalHisto[i] == 1)", will give signal on my sell condition.

But i can't get it give the signal on i+1, so the bar after my sell condition.

Weird.

 
Greg_:

Thanks for answers, it's on DAX, so 1pt is enough to see it :)

The loop go forward i++

How can you get a value for i+1 when you haven't calculated it yet ? new bars are attached to the right of the chart, your Indicator works left to right with real time data, why doesn't it work from left to right on historical data, i.e. i-- ?
 
Greg_: Thanks for answers, it's on DAX, so 1pt is enough to see it :)
Dax ranges 9300-9400 today, do you really think you can see two arrows separated by 0.01?
 

Thanks RaptorUK, i need to check that indeed :) That might be the issue i guess.

@WHRoeder, on the dax, "point" = 1 point, so not 0.01. On the screen you may have 50 point gap, so yes a 1pt difference you can see it :-)

Thanks guys!

 

Dax is quoted as 9,406.91 http://daytrading.about.com/od/marketprofiles/a/ProfileDAX.htm says "Tick size / Minimum price change : 0.5 "

You are confusing mt4's Point (0.01) and MODE_TICKSIZE of 0.50 with the DAX "point" (1 point=2 ticks=1.00)

 
Well, my experience is that some brokers have DAX futures with tick size 50c, some have CFD on DAX with tick size 1€, some 1c, some 0.1c so it is hard to generalize.
 
Ovo: Well, my experience is that some brokers have DAX futures with tick size 50c, some have CFD on DAX with tick size 1€, some 1c, some 0.1c so it is hard to generalize.
True and irrelevant to OP. He can not see two arrows placed 1 Point (0.01) apart.