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

[amibroker] Re: buy only if current position is zero



PureBytes Links

Trading Reference Links

You don't need to write a loop. Use ExRem.

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

However, if you plan to also backtest this code, then you would be better off to not use ExRem directly on Buy and Sell, but rather on temporary variables and plot the temporary variables instead.

e.g.

BuySignal = ExRem(Buy, Sell);
SellSignal = ExRem(Sell, BuySignal);
Plot(BuySignal, ...);
Plot(SellSignal, ...);

Note that a Plot is not guarenteed to be 100% in sync with a backtest since Plot does not take into account portfolio dynamics.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "noah.bender" <knowabender@xxx> wrote:
>
> That is true for the backtester but on the chart the code shows a 1 for buy and therefore plots an arrow. bc my code says if  buy plot......
> 
> Now i know i have to write a loop to prevent a buy from showing up, but I am not sure how???????? meaning a loop that will prevent a sell if I am in a buy. by using a variable? 
> 
> Can Anyone help?
> thanks 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > You don't need to do anything. That is the default built in behavior of AmiBroker (i.e. single position per symbol, redundant signals ignored).
> > 
> > http://www.amibroker.com/guide/afl/afl_view.php?name=setbacktestmode
> > 
> > Mike
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, zeek ing <zeeking57@> wrote:
> > >
> > > Is there a way to code
> > > that one should only buy if current position is zero?? Meaning one is
> > > currently not short. and vica versa. I can't seem to find away to this??
> > > 
> > > please help
> > >
> >
>




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

**** 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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto: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/