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

[amibroker] scale in & scale out



PureBytes Links

Trading Reference Links

Hello,

I want to try this idea on major stock index.

I want to be 100% invested in the index if c>ma(c,200), and want to be
50% invested in the index when c<ma(c,200)

I tried this AFL, and it seems to work.



Buy=true;//always have a position in the market
sell=cross(ma(c,200),c) or cross(c,ma(c,200));//on a cross of the
close above or below MA

positionsize=IIF(c>ma(c,200),-100,-50);//if c> ma then 100% Long else
50% long;

My questions are, is this a valid AFL? Does it do what I want it to do?

Second how can I code it for many stock index at a time? Let's say I
want to be 5% long when above and 2% long when below the moving average.

Any ideas appreciated

Antonio