Hi,
If you want to see the effects of stops, scaling, etc. then you can try
embedding a call to Equity in your script. Here's a quick example that
shows graphically where a stop (orange down arrow) would result in a
sell before the normal sell signal (red down arrow). The effect can be
seen on ^DJI of the default database for the period including feb/march
2010. Run as a exploration for Feb 24 - Feb 24 will show the stop being
generated as output.
With the call to Equity, the buy/sell arrays are updated before the
second plot, thus the difference in graphs. Also, since Filter comes
after the call to Equity, the output is based on the post backtested
arrays, which include integrated stops. If you comment out the call to
Equity, the graphs would be identical and the exploration output would
ignore stops.
Be sure to read up on the Equity function, including all comments which
describe the side effects. I haven't personally used this. So, do your
own testing.
This is, of course, a useless system constructed solely to illustrate
the point.
fast = MA(C, 5);
med = MA(C, 25);
slow = MA(C, 100);
Buy = Cross(fast, med);
Sell = Cross(med, slow);
ApplyStop(stopTypeNBar, stopModeBars, 3, 1);
Plot(Close, "Price", colorDarkGrey, styleBar);
Plot(fast, "Fast", colorGreen, styleLine);
Plot(med, "Med", colorRed, styleLine);
Plot(slow, "Slow", colorBlue, styleLine);
PlotShapes(Buy * shapeUpArrow + Sell * shapeDownArrow, IIf(Buy,
colorGreen, colorRed), 0, IIf(Buy, Low, High));
Equity(1, 0);
PlotShapes((Buy > 0) * shapeUpArrow + (Sell > 0) * shapeDownArrow,
IIf(Buy, colorBlue, colorOrange), 0, IIf(Buy, Low, High), -32);
Filter = Buy OR Sell;
AddColumn(IIf(Buy, Asc("B"), Asc("S")), "Signal", formatChar);
Mike
--- In [email protected], "ovtrad...@..." <ovtrad...@...> wrote:
>
>
>
>
> I'm not the original poster, but am dealing with the same issue. What
you suggest helps, and I can figure out how AmiBroker is encoding the
scale in data in the Buy/Short arrays. What about stops and profit
targets? They don't appear to be visible using the approach below.
Thanks.
>
>
> ovt
>
> --- In [email protected], "Mike" sfclimbers@ wrote:
> >
> > Steve,
> >
> > It's not clear to me what you are describing, particularly when you
say that you've combined signals into a few "Portfolios".
> >
> > To try and work around our differences in terminology, let me
describe the scenario I'm proposing, and see if it can be applied to
you.
> >
> > 1. Write AFL entry and exit rules in a script that we'll call
Rules.afl. This script can be run on any number of symbols. We'll call
the chosen symbols Watchlist 1. If you choose to only run it on 3
symbols, Watchlist 1 would contain only those 3 symbols.
> >
> > 2. Optimize Rules.afl to find best combination of parameters for
Watchlist 1.
> >
> > 3. Satisfied with step 2, change the default value of the Optimize
statements in Rules.afl to reflect the optimal combination.
> >
> > e.g.
> > x = Optimize("X", 5, 1, 10, 1); // Assuming 5 found to be optimal.
> >
> > 4. Add Exploration support to Rules.afl allowing output of new
signals.
> >
> > e.g.
> > Filter = Buy OR Sell;
> > AddColumn( IIf( Buy, Asc("B"), Asc("S")), "Signal", formatChar );
> >
> > 5. Run the exploration on Watchlist 1 every day before market open.
The resulting output would be along the lines of:
> >
> > SPY, 05/20/10, B <-- Buy SPY.
> > IWM, 05/20/10, S <-- Sell IWM.
> >
> > The above will allow you to run an exploration any time between
market close and the following market open. The output will be the
signals found in the most recent bar for which you have data (i.e. last
night), with which you will place orders during the next bar (i.e.
today).
> >
> > If your Buy and Sell arrays contain redundant signals, then use
ExRem to clear them out before generating the explore output.
> >
> > e.g.
> > UniqueBuy = ExRem(Buy, Sell);
> > UniqueSell = ExRem(Sell, UniqueBuy);
> > Filter = UniqueBuy OR UniqueSell;
> > AddColumn( IIf( UniqueBuy, Asc("B"), Asc("S")), "Signal", formatChar
);
> >
> > Mike
>