Hi Mike, I need to run optimize, and have spent a lot of time to add a custom column of MA on optimize result list and no luck so far.
Is it possible to find the bar index or bar number of buying and use the number to refer the MA like myMA = ref(MA(close, 6), -17); Thank you very much! Charles --- In [email protected], "Mike" <sfclimb...@...> wrote: > > Hi, > > There are a couple of problems: > > 1. When trying to do an equivalence test, use the equivalence operator '==' > not the assignment operator '='. > > 2. buyrule is an array. You cannot use the if statement on an array. > > If you just want to see what the value is, then run an exploration: > > Filter = buyrule; > AddColumn(MA(Close, 6), "MA(6)"); > > http://www.amibroker.com/guide/h_exploration.html > > Otherwise, add a custom metric to your backtest. > > Mike > > --- In [email protected], "chuck_win" <chaoy@> wrote: > > > > Hi, > > > > I do backtesting, and want to check MA at the time of buying. > > > > My code looks like > > > > buyrule = cross(MACD, signal); > > buy = buyrule; > > buyprice = close; > > sellrule = cross(signal, MACD); > > sell = sellrule; > > sellprice = close; > > if (buyrule = true) { > > str = StrFormat("%0.2f", MA(Close,6)); > > _TRACE(NumToStr( DateTime(), formatDateTime ) + ", " + str); > > > > } > > > > I always get the MA at the ending time of last bar instead. > > > > Thanks for any help! > > > > Charles > > >
