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

[amibroker] Re: AFL Programming Questions


  • Date: Tue, 09 Mar 2010 19:15:42 -0000
  • From: "Mike" <sfclimbers@xxxxxxxxx>
  • Subject: [amibroker] Re: AFL Programming Questions

PureBytes Links

Trading Reference Links

First and foremost, read the user guide:
http://www.amibroker.com/guide/

Specifically, familiarize yourself with every AFL function:
http://www.amibroker.com/guide/afl/afl_index.php?m=2

At which point your questions would be immediately answered without need for a "competent" group ;)

1. Foreign or SetForeign/RestorePriceArrays
http://www.amibroker.com/guide/afl/afl_view.php?id=54
http://www.amibroker.com/guide/afl/afl_view.php?id=247

2. SetPositionSize
http://www.amibroker.com/guide/afl/afl_view.php?name=setpositionsize

e.g.

SetForeign("$SPX");
SPXMA200 = MA(Close, 200);
Flag = Close > SPXMA200;
RestorePriceArrays();

// 5% size when above MA, 1 % otherwise
SetPositionSize(IIF(Flag, 5, 1), spsPercentOfEquity);

3. Sum
http://www.amibroker.com/guide/afl/afl_view.php?name=sum

e.g.
Buy = Sum(Close > MA(Close, 65), 3) == 3;

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "jchi18" <inbox.chi@xxx> wrote:
>
> Now that I've found a competent group that seems willing to help, I would like to pose some questions:
> 
> 1.  What is the best way to reference an index (i.e., S&P 500) and depending on the condition of that index the formula would indicate a buy signal for stock A or a sell signal for stock B?  I am trying to create a simple formula that trades two ETFs (MDY for longs and MYY for shorts).
> 
> 2.  Is there a way to change your position size depending on variables?  For instance, I would like to increase the size of my buys and decrease the size of my shorts in the case where the overall market (i.e., S&P500 close > its 200 MA) is in an uptrend.  And vice versa.
> 
> 3.  I have been reading some books and I wanted to emulate a formula that I read about.  It's very simple but I can't figure out how to do it simply.  If there are three consecutive closes above the 65 SMA, then buy.  If there are three consecutive closes below the 65 SMA then sell.  Any thoughts on how to do it?
> 
> Thanks again for everyone who helped me before.  I'm going to guess that you'll be hearing a lot from me.
>




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

**** 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

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/