Hi,

Despite being easier, copying the code would be the least desirable option, 
since it becomes a maintenance issue. Any future changes will need to be 
propagated to multiple locations.

Using #include_once allows you to have a "single point of truth". As your code 
evolves, this will likely become more and more of an issue for you.

To limit your exploration output to a single bar while still running over an 
extended period, you can play with the Filter statement. For example;

Bar = BarIndex();
Filter = Bar == LastValue(Bar);

The above will only print output for the last bar of each symbol. However, it 
does not attempt to verify that it will be the same bar for each symbol (e.g. 
if YYY had no data for today but ZZZ did, then you would have two different 
dates for the output). You can run with the idea and try to tune it to output 
for all the same date. Or, if you only work with symbols that you know have 
regular trading volume, then this could be good enough.

Mike

--- In [email protected], "lucianomt" <lucian...@...> wrote:
>
> 
> Thanks, I actually copied the code in the exploration AFL. 
> 
> My code uses a FOR statement to fill in the Buy and Sell signals. When I run 
> the exploration for one symbol, it displays all the trading days. I want the 
> exploration to show only the last bar, so that I can add other symbols and 
> there will be one line per symbol.
> 
> How can I just show the latest bar but still run the strategy for the 
> previous bars?
> 
> 
> 
> --- In [email protected], "Mike" <sfclimbers@> wrote:
> >
> > You can either add the exploration code to the existing strategy code, or 
> > #include_once the strategy file into a new exploration file.
> > 
> > http://www.amibroker.com/guide/afl/afl_view.php?name=%23include_once
> > 
> > One way to determine whether or not you are in a position is to use the 
> > Flip function.
> > 
> > http://www.amibroker.com/guide/afl/afl_view.php?id=51
> > 
> > Example;
> > 
> > Buy = ...
> > Sell = ...
> > Short = ...
> > Cover = ...
> > 
> > AmLong = Flip(Buy, Sell);
> > AmShort = Flip(Short, Cover);
> > 
> > // Output "L" when long, "S" when short, "F" when flat.
> > Filter = 1;
> > AddColumn(IIf(AmLong, Asc("L"), IIf(AmShort, Asc("S"), Asc("F"))), 
> > "Position", formatChar);
> > 
> > Mike
> > 
> > --- In [email protected], "lucianomt" <lucianomt@> wrote:
> > >
> > > I want to use the Exploration function to screen a watch list for 
> > > Buy/Sell signals generated by a strategy I already have. The Exploration 
> > > list should show the symbols and whether I am long, short or flat that 
> > > symbol according to the strategy.
> > > 
> > > Do I have to replicate the strategy code on the exploration code or can I 
> > > just refer to that strategy?  If so, how?
> > >
> >
>


Reply via email to