Think this is what your looking for. The concept of using an index as a filter for buying/selling. Any ticker in your database can be referenced using Foreign() function.The symbols bought will still depend on "Apply to" selection in Analysis window
Link to the manual
AFL Function Reference - FOREIGN
That's a link to a video
How to Add an Index Filter to your Amibroker Trading System
Posted by: brandon.richard03@yahoo.com
If I understand your question correctly, one could use this as an example to only allow a buy if ^GSPC is above its 50 day moving average.
// GSPC filter
GSPC = Foreign("^GSPC","Close");
GSPCUp = Market > MA(Market,50);
// MA Cross over system
SetOption( "InitialEquity", 10000 );
MaxPositions = 1;
SetOption("MaxOpenPositions", MaxPositions );
PositionSize = -100/MaxPositions ;
SetTradeDelays( 1, 1, 1, 1 );
BuyPrice = SellPrice = Open;
Vcond = V > 1000000;
Buy = Cross(EMA( Close, 9), EMA( Close, 21)) AND VCond AND C > 10 AND GSPCUp;
Sell = Cross(EMA( Close, 21), EMA( Close, 9)) AND VCond;
Buy = ExRem( Buy, Sell);
Sell = ExRem( Sell, Buy);
Filter = 1;
AddColumn(O, "Open");
AddColumn(C, "Close");
// End of the system
__._,_.___
Posted by: brandon.richard03@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
**** 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/
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/
.
__,_._,___
EmoticonEmoticon