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 [email protected], "noah.bender" <knowaben...@...> 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 [email protected], "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 [email protected], 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 > > > > > >
