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;
   



  ------------------------------------

  **** IMPORTANT PLEASE READ ****
  This group is for the discussion between users only.
  This is *NOT* technical support channel.

  TO GET TECHNICAL SUPPORT send an e-mail directly to 
  SUPPORT {at} amibroker.com

  TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
  http://www.amibroker.com/feedback/
  (submissions sent via other channels won't be considered)

  For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
  http://www.amibroker.com/devlog/

  Yahoo! Groups Links



Reply via email to