View Single Post
  #8 (permalink)  
Old 08-16-2007, 03:25 AM
mikeschra's Avatar
mikeschra mikeschra is offline
Junior Member
 
Join Date: Jan 2007
Posts: 9
mikeschra is on a distinguished road
Ok, Here I go again!

OK lets break this down:
case 1:buf1_down[i]=EMPTY_VALUE;buf1_up[i]=EMPTY_VALUE; if (haOpen>=haClose) buf1_down[i] = 1; else buf1_up[i] = 1; break;

It tells us buf1_down and buf1_up have initial values of EMPTY_VALUE!

So I trust every one has looked into “do some digging into the MetaEditor library for more info on all of the SetIndex functions”, right? Lol

Lets take a look at this: SetIndexEmptyValue(0,0.0);
This is telling us that SetIndexBuffer of 0 (buf1_up ) will equal 0.0 for the buf1_up value as defult. This is also true for the other 7 SetIndexBuffer parameters will also equal 0.0 but (remember that the SetIndexBuffer value returtned is the data we are using to code our EA and for this indicator and we have 8 total!)

So now we look at this:
“case 1:buf1_down[i]=EMPTY_VALUE;buf1_up[i]=EMPTY_VALUE; if (haOpen>=haClose) buf1_down[i] = 1; else buf1_up[i] = 1; break;”
Witch means :buf1_down AND buf1_up always = 0.0(EMPTY_VALUE ). So if the open is greater than or equal to the close, buf1_down will = 1 else this happens--- else buf1_up will =1!. Remember buf1_down is our Mode of 1(SetIndexBuffer(1,buf1_down)

So now we know that for the lowest time frame of the N4 TF HAS Bar we will use for our mode value of 0 or 1. One will produce a value of 0.0 and the other will produce a value of 1.

Here is a quick example of how you would code this.
Bar1Up=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,0,0);
Bar1Down=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,1,0);

Continued syntax code adding the MODE: iCustom(Null,0, “N4 TF HAS Bar”,MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth, BarColorUp,BarColorDown,TextColor,MaxBars,0

Shift: This is how many bars ago or the current bar you want to use. 0 = current bar (Note that using current bar values change throughout the time frame you are on. Example: if your code uses a current bar on close….well…when does a current bar close? Its close is the last tick for that bar! So every tick for the bar you are on is the close of that bar.)

Continued syntax code adding the Shift: iCustom(Null,0, “N4 TF HAS Bar”,MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth, BarColorUp,BarColorDown,TextColor,MaxBars,0,0)

This completes the syntax code for the N4 TF HAS Bar.

Here’ some code to help untangle the rest.

Values returned by Has Bar Indicator
Bar1UpOrDown == 1 or Empty, Bar2UpOrDown == 2 or Empty
Bar3UpOrDown == 3 or Empty, Bar4UpOrDown == 4 or Empty

Bar1Up=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,0,0;
Bar1Down=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,1,0;
Bar2Up=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,2,0;
Bar2Down=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,3,0;
Bar3Up=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,4,0;
Bar3Down=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,5,0;
Bar4Up=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,6,0;
Bar4Down=iCustom(NULL,0," N4 TF HAS Bar ",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,Bar ColorUp,BarColorDown,TextColor,MaxBars,7,0;

Hope some one finds this helpful! Now I need that 4th beer!
Reply With Quote