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

[amibroker] custom equity function for a foreign ticker



PureBytes Links

Trading Reference Links

I'd like to show the buy and hold equity curves of 2 securities on the same
chart. the buy and hold part of AB's built-in equity line is this:

---------------------------------------
	Short = Cover = 0;
	Buy = Status("firstbarintest");
	Sell = Status("lastbarintest");
	SetTradeDelays(0, 0, 0, 0);
	PositionSize = -100;
	ApplyStop(0, 0, 0, 0);
	ApplyStop(1, 0, 0, 0);
	ApplyStop(2, 0, 0, 0);
	Plot(Equity(0, -2), "Equity", colorBlue);
---------------------------------------

that code works for me too, but it's tied to the current ticker. so, I wrote
the following function, which doesn't work at all, even when passed the
current ticker symbol; it returns a flat line at 10,000.

---------------------------------------
function EquityCalc(Ticker) {
	// buy and hold simulation, after AB's built-in Equity Line
	saveO = O;
	saveH = H;
	saveL = L;
	saveC = C;
	saveV = V;
	O = Foreign(Ticker, "O");
	H = Foreign(Ticker, "H");
	L = Foreign(Ticker, "L");
	C = Foreign(Ticker, "C");
	V = Foreign(Ticker, "V");
	Short = Cover = 0;
	Buy = Status("firstbarintest");
	Sell = Status("lastbarintest");
	SetTradeDelays(0, 0, 0, 0);
	PositionSize = -100;
	ApplyStop(0, 0, 0, 0);
	ApplyStop(1, 0, 0, 0);
	ApplyStop(2, 0, 0, 0);
	e = Equity(0, -2);
	O = saveO;
	H = saveH;
	L = saveL;
	C = saveC;
	V = saveV;
	return e;
}
---------------------------------------

what's wrong with this picture? I'm saving the current price and volume
arrays, calculating equity, then restoring them and returning the equity
result. even if, for test purposes, I don't do the save and recall, but just
run the equity calc in a function, it's not working. there must be some
other context I'm not bringing into the function that's required for Equity
to work, but I don't know what that might be, or where to find out.

thanks for any help,

Dave Merrill


------------------------ 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/l.m7sD/LIdGAA/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 

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