Thank you both for your help. Your comments and samples helped me to get a grasp of this.
Thanks DM --- In [email protected], "Mr. Duke Jones" <d...@...> wrote: > > Bill, is correct that iif is the issue. I think you want to use the > Writeif function for what your looking to do. For example adding this > bit of code will get you the attached exploration output. > > //Exploration Cell colors > PosTxtclr = IIf(PosDiv==1, colorWhite,colorWhite); > Posbkclr = IIf(PosDiv==1, colorLime,colorWhite); > NegTxtclr = IIf(NegDiv==1, colorBlack,colorLime); > Negbkclr = IIf(NegDiv==1, colorRed,colorWhite); > > //Turn Signals to Text Cell Output > > AddTextColumn(WriteIf(PosDiv==1,"Positive",WriteIf > (PosDiv==0,"","")),"Positive",1.2, Postxtclr, Posbkclr); > AddTextColumn(WriteIf(NegDiv==1,"Negative",WriteIf > (NegDiv==0,"","")),"Negative",1.2, Negtxtclr, Negbkclr); > > > > > Regards, > > Duke Jones, CMT > > On Sep 22, 2009, at 10:27 PM, wavemechanic wrote: > > > > > The plots are correct but your IIF() is incorrect (assign it to a > > variable and it will return the value of the 2nd or 3rd parameter). > > I just checked and the code that I listed works as I described so > > you can start there and modify as desired if this is not what you > > want. > > > > Bill > > ----- Original Message ----- > > From: dmcleod1981 > > To: [email protected] > > Sent: September 22, 2009 7:05 PM > > Subject: [amibroker] Re: Code Question > > > > Bill, Thanks for taking a look at this for me. I have looked at the > > section you described but I guess I am a little slow at this. I > > replaced using == etc but no change. I am not sure if you plotted > > this but the plots seem correct. The problem is when I use an > > exploration so I guess I am not making a connection as to where its > > off. I will go back and re-read that section as see if this thick > > head can make sense of it. > > > > Thanks > > DM > > > > --- In [email protected], "wavemechanic" <fimdot@> wrote: > > > > > > You have a problem with the way IIF() is used. See "Common Coding > > Mistakes" in the Users Guide. > > > > > > From your description, I assume that you want to go through your > > symbols, characterize the last value of the divergence and associate > > the divergence with a symbol. If so, a simple way is to replace the > > code after the Plot() section with the following which will put 1 or > > 0 in the divergence columns. > > > > > > addtextcolumn(name(), "symbol", 1.2, colorblack); > > > addcolumn(posdiv, "posdiv", 1.2, colorlime); > > > addcolumn(negdiv, "negdiv", 1.2, colorred); > > > filter = status("lastbarinrange"); > > > > > > Bill > > > ----- Original Message ----- > > > From: dmcleod1981 > > > To: [email protected] > > > Sent: September 22, 2009 10:55 AM > > > Subject: [amibroker] Code Question > > > > > > > > > I found this code in the TASC articles in the member section. I > > was trying to add some code to be able to run an explore to possible > > divergences. When I plot the indicator it seems to be correct but in > > the columns both conditions show true. It is a simple code mistake > > but at the moment it escapes me why. Can anyone point out the > > obvious to me? > > > > > > Thanks > > > DM > > > > > > /*TWO-POINT PROBLEM OF THE RATE OF CHANGE > > > > > > In the "Two-point problem of the Rate Of Change" article Martti > > Luoma AND Jussi Nikkinen > > > present the modification of classic ROC indicator that can be > > constructed two ways in AmiBroker. > > > First way does NOT require writing any single line of code. You > > can construct ROCadj AND other > > > indicators using AmiBroker's powerful drag AND drop technology. > > To create ROCadj, select Chart tab, > > > go to Indicators folder, double click on ROC - Rate Of Change - > > this will create new chart pane with ROC. > > > Then go to Averages folder, click AND drag EMA - Exponential > > Moving Average onto ROC chart. > > > Your indicator is ready. Now simply adjust ROC period to 1 AND > > EMA smoothing period to 21 using > > > Parameters window. Second way is to use the formula presented in > > Listing 1. Just type it into > > > Formula Editor AND press Insert Chart button. > > > */ > > > > > > periods = Param("Periods", 21, 2, 200, 1 ); > > > ROCadj = periods * EMA( ROC( C, 1 ), periods ); > > > > > > /*Added Divergence to original formula*/ > > > > > > RocSlope=LinRegSlope(ROC(C,periods),periods); > > > MARocSlope=LinRegSlope(ROCadj,periods); > > > PosDiv=MARocSlope>=RocSlope; > > > NegDiv=MARocSlope<RocSlope; > > > > > > > > > //Plots > > > Plot( ROCadj, "ROCadj "+periods, colorRed, styleThick ); > > > // the line below adds standard ROC overlay > > > Plot( ROC( C, periods ), "ROC "+periods, colorBlue ); > > > > > > Plot(PosDiv,"Positive",colorLime,styleOwnScale); > > > Plot(NegDiv,"Positive",colorRed,styleOwnScale); > > > IIf(PosDiv>0,AddTextColumn("Positive","Positive Divergence", > > 1.2,colorLime),0); > > > IIf(NegDiv>0,AddTextColumn("Negative","Negative Divergence", > > 1.2,colorRed),0); > > > > > > Filter=1; > > > > > > > > > >
