And here's what I settled on.  Tacking this code on the end of my formula and 
running it as an exploration satisfies my requirements:

Equity(1);

function formatexitarray(in, def)
{
        //1=normal exit, default character used, X=stop, P=profit target, 
T=trailing stop, N=n-bar
        return IIf(in==1, Asc(def), IIf(in==2, Asc("X"), IIf(in==3, Asc("P"), 
IIf(in==4, Asc("T"), IIf(in==5, Asc("N"), Asc(" "))))));
}

Filter = Buy OR Sell OR Short OR Cover;

AddColumn(IIf(Buy==1, Asc("B"), IIf(Buy==sigScaleIn, Asc("I"), Asc(" "))), 
"Buy", formatChar);
AddColumn(formatexitarray(Sell, "S"), "Sell", formatChar);
AddColumn(IIf(Short==1, Asc("S"), IIf(Short==sigScaleIn, Asc("I"), Asc(" "))), 
"Short", formatChar);
AddColumn(formatexitarray(Cover, "C"), "Cover", formatChar);

// Uncomment this section of code if you want to see what's being encoded in 
the arrays
/*
AddColumn(Buy, "Buy Raw");
AddColumn(Sell, "Sell Raw");
AddColumn(Short, "Short Raw");
AddColumn(Cover, "Cover Raw");
*/

// Sort by date descending
SetSortColumns(-2);


ovt

--- In amibroker@yahoogroups.com, "ovtrad...@..." <ovtrad...@...> wrote:
>
> 
> 
> Mike -- thanks for taking the time to do this, it looks like that will do the 
> trick.  Will check it out.
> 
> ovt
> 
> --- In amibroker@yahoogroups.com, "Mike" <sfclimbers@> wrote:
> >
> > 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
>


Reply via email to