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

Re: [amibroker] Re: Sell n days later



PureBytes Links

Trading Reference Links

I tried to use ApplyStop as you suggested. It worked as expected for the initial trades, but subsequent trades were exited on the same bar as entered for new symbols that were not one of the initial ones as selected by PositionScore.

Apparently the ApplyStop applies to all buy signals whether chosen by PositionScore or not, and the stop beginning bar for a symbol is only reset by exiting an actually held position. So new buys selected by PositionScore are already past the number of bars specified in ApplyStop since they haven't been reset, hence immediate exit. For reasons I don't understand, these new buys are not selected on the next bar or ever again. However if an initially held position is exited by the stop, and remains in the top rank by PositionScore, it will be held for the proper duration of the stop as reset by the new trade.

Here's the simplified code I used to see if the concept worked.

SetOption("MaxOpenPositions", 3);
SetOption("InitialEquity", 10000);
SetTradeDelays( 1, 1, 1, 1 );
PositionSize=1000;
Buy = 1;
Sell =0;
ApplyStop(stopTypeNBar, stopModeBars, 10);
PositionScore= ROC(Close,30);

I can see what is happening but don't have any solution to get my desired result.



On 6/7/05, Christoper <chrisismyname@xxxxxxxxx> wrote:
Lookup Applystop in the Help Files

--- In amibroker@xxxxxxxxxxxxxxx, Esteban <EstebanUno@xxxx> wrote:
> I'm new to AmiBroker, and I'm trying to code a simple ranking
system. I was
> hoping to use the rotational trading function, but I don't think I
can add
> an additional sell parameter using this.
>
> I want to buy and remain in the top 10 ranked issues according to my
ranking
> criteria. I want to replace a position when it falls out of the top
10 but
> not until it has been held for a minimum of 30 days.
>
> I don't understand how to access the position entry date of the
individual
> issues to see if 30 days has passed. Here's the idea.
>
> SetOption("MaxOpenPositions", 10)
> Sell = (30 days have passed since opening the position)
> Buy = True
> PositionScore= myRankingScheme
>
> Forgive my crude attempt at coding, my understanding of the concepts
are
> hazy. I have no idea how to quantify the Sell variable to indicate
30 days
> have passed for a particular position. I believe if Sell was set to
true,
> the portfolio would always contain the top 10 positions without the
30 day
> qualifier. If sell was set to false the portfolio would remain in the
> original top 10 positions. Correct me if I'm wrong.
>
> Thanks for helping me get started.






Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links