PureBytes Links
Trading Reference Links
|
Jolly,
You can't override the range dates once you're already being executed. It's a chicken and egg thing. However, if you include conditional logic to only accept signals during specific periods, then you can run the backtest over the a timeframe that includes all periods and the code will prevent trading except during allowed periods.
e.g. Trade only during 2003 and 2005, vertical bars over green squares will be accepted, others will be ignored.
Dates = DateNum(); ValidDates = (Dates >= 1030101 && Dates <= 1031231) || (Dates >= 1050101 && Dates <= 1051231);
MyBuySignal = Cross( MACD(), 0 ); Buy = MyBuySignal AND ValidDates;
MySellSignal = Cross( 0, MACD()); Sell = MySellSignal AND ValidDates;
DateColors = IIF(ValidDates, colorGreen, colorLightGrey);
Plot(1, "", DateColors, styleArea | styleOwnScale | styleNoLabel); Plot(MyBuySignal, "Buy Signal", colorGreen, styleHistogram, styleOwnScale); Plot(MySellSignal, "Sell Signal", colorRed, styleHistogram, styleOwnScale);
Title = NumToStr(DateTime(), formatDateTime) + ", " + EncodeColor(colorGreen) + "Buy Signal: " + MyBuySignal + ", " + EncodeColor(colorRed) + " Sell Signal: " + MySellSignal;
Alternatively, have a look at BatMan in the Files section of this group and write a batch script to run your backtests over each of the desired periods.
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "jollypolly999" <jollypolly999@xxx> wrote: > > > Hi, > > It's not that surprising that you would not get any signals. Your > buy/sell criteria are very rigid. The Cross of the MACD would have to > happen on exactly the dates that you specified, else your criteria > would > not be met. Also, I can't tell whether you've used a zero or the letter > 'O' for the second argument to Cross. On my test symbol, using zero I > get signals, using the letter 'O' (i.e. Open) I do not. > > Thanks again Mike, > > The date ranges are to run a backtest within, not to open and close > trades. So within the specified dates, any buy/sell signal will be > traded. The code will only need to define the backtest range and > over-ride the backtester settings. Not to open and close trades. > > Yes the O and 0 were typographical errors for that post. Sorry. > > To help with debugging, use the following code. If you do not see a > vertical green bar line up over top of a green square along the base, > then your buy signal did not occur on a valid buy date. Likewise for > selling, if a vertical red bar does not line up over top of a red > square, then your sell signal did not line up over a valid sell date. > > Mike >
__._,_.___
**** 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/
__,_._,___
|