[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Fw: How about



PureBytes Links

Trading Reference Links

Have been studying AFL and ran across the following code puzzle.  
Comments should explain the mystery I have encountered.



/*
Simple Buy / Sell Indicator based on a % Increase / Decrease
*/

LookBack = Param("Lookback Periods", 12, 5, 40); // No adjustment 
required if code functions properly - Just set it at 25 or so.
SetPoint = Param("Buy/Sell %",8,4,10);
Color = IIf(C >=Ref(C,-1),colorGreen,colorRed);
Yscale = 50;

Title = " " + Name() + " - " + EncodeColor(colorRed) +Setpoint + "%" 
+ EncodeColor(colorGreen) + "  Buy " + EncodeColor(colorBlack) 
+ " / " + EncodeColor(colorRed) + " Sell  (" + LookBack + ") "; 

// Search backwards to find the first occurence of HHV or LLV that 
exceeds % setpoint
N = 1;
do 
{
   Change = ((C - LLV(C,N)) / LLV(C,N)) * 100;   // Percent change
   Buy = Cross(Change,Setpoint);

   Change = ((C - HHV(C,N)) / HHV(C,N)) * 100;   // Percent change
   Sell = Cross(-Setpoint,Change);

   // Catch the first HHV or LLV exceeding the setpoint, exit the 
search loop and display it. 
   // Can't figure out why the next line NEVER finds a Buy or Sell !!
   // In fact, can't find any other test that will !!
   N = IIf(LastValue(Buy OR Sell), LookBack + 1, N + 1);
} while(N <= LookBack);

Buy = ExRem(Buy, Sell);   Sell = ExRem(Sell, Buy);

GraphXSpace = 1000;
PlotShapes(shapeSmallCircle,Color,0,Yscale, Offset = 0);  // Display 
a base line
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,Yscale - 1);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,Yscale + 1);



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
     amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/