[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] getting data from barchart.com



PureBytes Links

Trading Reference Links


 
 I don't know anything about what you are trying to do or if it can be done, but I do know that Yahoo offers data for most ALL commodities and futures.  I know this because I went to a meeting about 2 months ago and 2 people their were using Market Warrior, and they were downloading FREE commodities and futures data off of yahoo along with the FREE stock-ETF etc. data.
 The Market Warrior downloader seemed to work similar to most of that type downloading software.  You just needed the symbols and the web URL.
 So I would think that AmiQuote could be able to do the same thing, but not sure.
 The people that were using Market Warrior said though that there was no history price data for the commodity markets on yahoo.  So you only have the data from where you started downloading and they had to download each and every night to be sure they have the data.
 
 Maybe one day yahoo, google or some others will offer all markets like some do stocks now.  With history and updated data.
 
 I was wondering.  Would it be legal for someone like me to take my data and offer it for free on a website, for anyone who wants to use it?
 
----- Original Message -----
From: krishna
Sent: Monday, December 22, 2008 12:06 AM
Subject: [amibroker] getting data from barchart.com

Hi All,
 
i am using amibroker ver 4.80. there is a website www.barchart.com that gives end of day o,h.l.c for most of the US commodity futures. can some one explain or help me can i get the data from this website to amibroker. in amiquote i could find the provision to use only listed websites like yahoo.com or quotes.com. for instance i am giving the link below of barchart.com. "
http://www2.barchart.com/futexch.asp?exch=nymex&code=BSTK" this link gives the eod for crude oil pit trading. now i can i get these quotes to amibroker software.
 
thanks for the attention and help.
 
rgds
 
krish

--- On Fri, 19/12/08, amibroker@xxxxxxxxxps.com <amibroker@xxxxxxxxxps.com> wrote:
From: amibroker@xxxxxxxxxps.com <amibroker@xxxxxxxxxps.com>
Subject: [amibroker] Digest Number 8388
To: amibroker@xxxxxxxxxps.com
Date: Friday, 19 December, 2008, 10:22 PM

Messages In This Digest (25 Messages)

1a.
Automation to load an AFL and run Portfolio Optimization From: ozzyapeman
1b.
Re: Automation to load an AFL and run Portfolio Optimization From: ozzyapeman
1c.
Re: Automation to load an AFL and run Portfolio Optimization From: ozzyapeman
1d.
Re: Automation to load an AFL and run Portfolio Optimization From: Mike
1e.
Re: Automation to load an AFL and run Portfolio Optimization From: Mike
1f.
Re: Automation to load an AFL and run Portfolio Optimization From: ozzyapeman
1g.
Re: Automation to load an AFL and run Portfolio Optimization From: dingo
1h.
Re: Automation to load an AFL and run Portfolio Optimization From: ozzyapeman
1i.
Re: Automation to load an AFL and run Portfolio Optimization From: Paul Ho
1j.
Re: Automation to load an AFL and run Portfolio Optimization From: Tomasz Janeczko
2a.
Re: scrolling through a watchlist From: Mike
2b.
Re: scrolling through a watchlist From: jim fenster
2c.
Re: scrolling through a watchlist From: Mike
2d.
Re: scrolling through a watchlist From: Mike
3a.
Re: Off-Topic : recover lost file (Thanks : it is URGENT) From: sumangalam
4a.
Re: help for indicator and IIF issue From: Paolo Cavatore
5.
How to draw indicator in time lag? From: maximoff_max
6a.
Re: Synergy trading system From: Howard B
7a.
Re: y-axis value for crosshair From: reinsley
8a.
Re: ADR Index and IB TWS From: Keith McCombs
9.
Plot higher Timeframe EMA on 1M chart From: Haresh Patel
10.
PlotText in a loop From: reinsley
11a.
Accessing data from time frame lesser than selected chart time inter From: nagkiran_k
11b.
Re: Accessing data from time frame lesser than selected chart time i From: Tomasz Janeczko
12.
Current bar value in the array? From: r_terbush

Messages

1a.

Automation to load an AFL and run Portfolio Optimization

Posted by: "ozzyapeman" zoopfree@xxxxxxxxcom   ozzyapeman

Thu Dec 18, 2008 5:02 pm (PST)

Hoping someone can chime in here to let me know what I might be doing
wrong. I'm currently testing out some simple automation code. The
objective is to load an AFL and then run a portfolio optimization for a
specified date range.

I am using a simple MA crossover trading system for testing purposes. I
can of course optimize it manually in AA without any problem. But when I
try to run and control that optimization from a piece of automation
code, I get a whole range of syntax errors.

Below are the two *separate* AFL codes. I imagine the first AFL has some
errors in it that is preventing the actions from being carried out
properly. What am I missing or doing wrong? Any input much appreciated:

//---------- --------- --------- --------- --------- --------- ---\
------
// AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
//---------- --------- --------- --------- --------- --------- ---\
------

EnableScript( "jscript" );
<%

database = "C:\\Program Files\\Amibroker\ \Data";
formula_1 = "C:\\Simple MA Cross.afl";

AB = new ActiveXObject( "Broker.Application " );
AB.LoadDatabase( database );
AA = AB.Analysis;
Stk = AB.Stocks
Doc = AB.Documents. Open( Stk.Ticker );

AA.LoadFormula( formula_1 ); // load formula from external
file

AA.ApplyTo = 1; // use current symbol
AA.RangeMode = 3; // use 'From' and 'To' dates
AA.RangeFromDate = "11/01/2005" ;
AA.RangeToDate = "12/31/2005" ;
AA.Optimize( 0 ); // run Optimize for the
portfolio, which is just one symbol
AA.Backtest( );

%>
//---------END AUTOMATION
AFL--------- --------- --------- --------- --------- ----

//---------- --------- --------- --------- --------- --------- ---\
------
// Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple MA
Cross.afl"
//---------- --------- --------- --------- --------- --------- ---\
------

FastMALength = Optimize("FastMALen gth", 1, 1, 100, 1);
SlowMALength = 20;

//---------- --------- --------- --------- --------- --------- ---\
------
// BACKTESTER SETTINGS
//---------- --------- --------- --------- --------- --------- ---\
------

SetBarsRequired( 10000, 0);
SetOption("AllowPos itionShrinking" , False);
SetOption("AllowSam eBarExit" , True);
SetOption("Commissi onAmount" , 3.00);
SetOption("Commissi onMode", 3);
SetOption("FuturesM ode", 1);
SetOption("InitialE quity", 100000);
SetOption("Interest Rate",0);
SetOption("MaxOpenP ositions" , 1);
SetOption("MinPosVa lue", 0);
SetOption("MinShare s", 1);
SetOption("PriceBou ndChecking" , False );
SetOption("ReverseS ignalForcesExit" , False);
SetOption("UsePrevB arEquityForPosSi zing", True );
SetTradeDelays( 0, 0, 0, 0);
SetPositionSize( 1, spsShares);
TickSize = 0.0001; // The minimum price move of symbol for Forex
PointValue = 100000;
RoundLotSize = 1;
MarginDeposit = 2500;
BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;

//---------- --------- --------- --------- --------- --------- ---\
--
// TRADING SYSTEM
//---------- --------- --------- --------- --------- --------- ---\
--

FastMA = MA( C, FastMALength );
SlowMA = MA( C, SlowMALength );
Buy = Cross( FastMA, SlowMA );
Sell = Cross( SlowMA, FastMA );

1b.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "ozzyapeman" zoopfree@xxxxxxxxcom   ozzyapeman

Thu Dec 18, 2008 6:12 pm (PST)

The simplified code below runs without any syntax error. However,
instead of optimizing through all 100 steps, it only does a single step.
Any idea why doesn't it do all 100 steps, as coded in the Simple MA
Cross afl?:

//---------- --------- --------- --------- --------- --------- ---\
------
// AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
//---------- --------- --------- --------- --------- --------- ---\
------

EnableScript( "jscript" );
<%

database = "C:\\Program Files\\Amibroker\ \Data";
formula_1 = "C:\\Simple MA Cross.afl";

AB = new ActiveXObject( "Broker.Application " );
AB.LoadDatabase( database );
AA = AB.Analysis;

AA.LoadFormula( formula_1 ); // load formula from external
file

AA.ApplyTo = 1; // use current symbol
AA.RangeMode = 3; // use 'From' and 'To' dates
AA.RangeFromDate = "11/01/2005" ;
AA.RangeToDate = "12/31/2005" ;
AA.Optimize( 0 ); // run Optimize for the
portfolio, which is just one symbol
//AA.Backtest( );

%>
//---------END AUTOMATION
AFL--------- --------- --------- --------- --------- ----

--- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@xx .> wrote:
>
> Hoping someone can chime in here to let me know what I might be doing
> wrong. I'm currently testing out some simple automation code. The
> objective is to load an AFL and then run a portfolio optimization for
a
> specified date range.
>
> I am using a simple MA crossover trading system for testing purposes.
I
> can of course optimize it manually in AA without any problem. But when
I
> try to run and control that optimization from a piece of automation
> code, I get a whole range of syntax errors.
>
> Below are the two *separate* AFL codes. I imagine the first AFL has
some
> errors in it that is preventing the actions from being carried out
> properly. What am I missing or doing wrong? Any input much
appreciated:
>
>
//---------- --------- --------- --------- --------- --------- ---\
\
> ------
> // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
>
//---------- --------- --------- --------- --------- --------- ---\
\
> ------
>
> EnableScript( "jscript" );
> <%
>
> database = "C:\\Program Files\\Amibroker\ \Data";
> formula_1 = "C:\\Simple MA Cross.afl";
>
> AB = new ActiveXObject( "Broker.Application " );
> AB.LoadDatabase( database );
> AA = AB.Analysis;
> Stk = AB.Stocks
> Doc = AB.Documents. Open( Stk.Ticker );
>
> AA.LoadFormula( formula_1 ); // load formula from
external
> file
>
> AA.ApplyTo = 1; // use current symbol
> AA.RangeMode = 3; // use 'From' and 'To' dates
> AA.RangeFromDate = "11/01/2005" ;
> AA.RangeToDate = "12/31/2005" ;
> AA.Optimize( 0 ); // run Optimize for the
> portfolio, which is just one symbol
> AA.Backtest( );
>
> %>
> //---------END AUTOMATION
> AFL--------- --------- --------- --------- --------- ----
>
>
>
>
>
>
//---------- --------- --------- --------- --------- --------- ---\
\
> ------
> // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple MA
> Cross.afl"
>
//---------- --------- --------- --------- --------- --------- ---\
\
> ------
>
>
> FastMALength = Optimize("FastMALen gth", 1, 1, 100, 1);
> SlowMALength = 20;
>
>
//---------- --------- --------- --------- --------- --------- ---\
\
> ------
> // BACKTESTER SETTINGS
>
//---------- --------- --------- --------- --------- --------- ---\
\
> ------
>
> SetBarsRequired( 10000, 0);
> SetOption("AllowPos itionShrinking" , False);
> SetOption("AllowSam eBarExit" , True);
> SetOption("Commissi onAmount" , 3.00);
> SetOption("Commissi onMode", 3);
> SetOption("FuturesM ode", 1);
> SetOption("InitialE quity", 100000);
> SetOption("Interest Rate",0);
> SetOption("MaxOpenP ositions" , 1);
> SetOption("MinPosVa lue", 0);
> SetOption("MinShare s", 1);
> SetOption("PriceBou ndChecking" , False );
> SetOption("ReverseS ignalForcesExit" , False);
> SetOption("UsePrevB arEquityForPosSi zing", True );
> SetTradeDelays( 0, 0, 0, 0);
> SetPositionSize( 1, spsShares);
> TickSize = 0.0001; // The minimum price move of symbol for
Forex
> PointValue = 100000;
> RoundLotSize = 1;
> MarginDeposit = 2500;
> BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
>
>
//---------- --------- --------- --------- --------- --------- ---\
\
> --
> // TRADING SYSTEM
>
//---------- --------- --------- --------- --------- --------- ---\
\
> --
>
> FastMA = MA( C, FastMALength );
> SlowMA = MA( C, SlowMALength );
> Buy = Cross( FastMA, SlowMA );
> Sell = Cross( SlowMA, FastMA );
>

1c.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "ozzyapeman" zoopfree@xxxxxxxxcom   ozzyapeman

Thu Dec 18, 2008 6:18 pm (PST)

To add to my confusion, sometimes the below code does produce syntax
errors when applied. Other times it runs smoothly (albeit with a
single optimization step). I'm not doing anything different, so I have
no idea why it fluctuates.

--- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@xx .> wrote:
>
> The simplified code below runs without any syntax error. However,
> instead of optimizing through all 100 steps, it only does a single step.
> Any idea why doesn't it do all 100 steps, as coded in the Simple MA
> Cross afl?:
>
>
>
//---------- --------- --------- --------- --------- --------- ---\
> ------
> // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
>
//---------- --------- --------- --------- --------- --------- ---\
> ------
>
> EnableScript( "jscript" );
> <%
>
> database = "C:\\Program Files\\Amibroker\ \Data";
> formula_1 = "C:\\Simple MA Cross.afl";
>
> AB = new ActiveXObject( "Broker.Application " );
> AB.LoadDatabase( database );
> AA = AB.Analysis;
>
> AA.LoadFormula( formula_1 ); // load formula from external
> file
>
> AA.ApplyTo = 1; // use current symbol
> AA.RangeMode = 3; // use 'From' and 'To' dates
> AA.RangeFromDate = "11/01/2005" ;
> AA.RangeToDate = "12/31/2005" ;
> AA.Optimize( 0 ); // run Optimize for the
> portfolio, which is just one symbol
> //AA.Backtest( );
>
> %>
> //---------END AUTOMATION
> AFL--------- --------- --------- --------- --------- ----
>
>
>
> --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> >
> > Hoping someone can chime in here to let me know what I might be doing
> > wrong. I'm currently testing out some simple automation code. The
> > objective is to load an AFL and then run a portfolio optimization for
> a
> > specified date range.
> >
> > I am using a simple MA crossover trading system for testing purposes.
> I
> > can of course optimize it manually in AA without any problem. But when
> I
> > try to run and control that optimization from a piece of automation
> > code, I get a whole range of syntax errors.
> >
> > Below are the two *separate* AFL codes. I imagine the first AFL has
> some
> > errors in it that is preventing the actions from being carried out
> > properly. What am I missing or doing wrong? Any input much
> appreciated:
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> >
> > EnableScript( "jscript" );
> > <%
> >
> > database = "C:\\Program Files\\Amibroker\ \Data";
> > formula_1 = "C:\\Simple MA Cross.afl";
> >
> > AB = new ActiveXObject( "Broker.Application " );
> > AB.LoadDatabase( database );
> > AA = AB.Analysis;
> > Stk = AB.Stocks
> > Doc = AB.Documents. Open( Stk.Ticker );
> >
> > AA.LoadFormula( formula_1 ); // load formula from
> external
> > file
> >
> > AA.ApplyTo = 1; // use current symbol
> > AA.RangeMode = 3; // use 'From' and 'To' dates
> > AA.RangeFromDate = "11/01/2005" ;
> > AA.RangeToDate = "12/31/2005" ;
> > AA.Optimize( 0 ); // run Optimize for the
> > portfolio, which is just one symbol
> > AA.Backtest( );
> >
> > %>
> > //---------END AUTOMATION
> > AFL--------- --------- --------- --------- --------- ----
> >
> >
> >
> >
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple MA
> > Cross.afl"
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> >
> >
> > FastMALength = Optimize("FastMALen gth", 1, 1, 100, 1);
> > SlowMALength = 20;
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> > // BACKTESTER SETTINGS
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> >
> > SetBarsRequired( 10000, 0);
> > SetOption("AllowPos itionShrinking" , False);
> > SetOption("AllowSam eBarExit" , True);
> > SetOption("Commissi onAmount" , 3.00);
> > SetOption("Commissi onMode", 3);
> > SetOption("FuturesM ode", 1);
> > SetOption("InitialE quity", 100000);
> > SetOption("Interest Rate",0);
> > SetOption("MaxOpenP ositions" , 1);
> > SetOption("MinPosVa lue", 0);
> > SetOption("MinShare s", 1);
> > SetOption("PriceBou ndChecking" , False );
> > SetOption("ReverseS ignalForcesExit" , False);
> > SetOption("UsePrevB arEquityForPosSi zing", True );
> > SetTradeDelays( 0, 0, 0, 0);
> > SetPositionSize( 1, spsShares);
> > TickSize = 0.0001; // The minimum price move of symbol for
> Forex
> > PointValue = 100000;
> > RoundLotSize = 1;
> > MarginDeposit = 2500;
> > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > --
> > // TRADING SYSTEM
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > --
> >
> > FastMA = MA( C, FastMALength );
> > SlowMA = MA( C, SlowMALength );
> > Buy = Cross( FastMA, SlowMA );
> > Sell = Cross( SlowMA, FastMA );
> >
>

1d.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "Mike" sfclimbers@xxxxxxcom   sfclimbers

Thu Dec 18, 2008 6:33 pm (PST)

Are you particularly looking to run the first script from AmiBroker?
Since the whole thing is intended to just be a batch starter, you can
just write it as a vanilla JScript file and run it directly from the
command line.

Just rename it to have a .js file extension (e.g. runami.js) then run
it from the command line using:

wscript runami.js

That being said. There are a few issues with your original post.
1. It's not clear what you are trying to do with the Stocks object and
your usage of Document. I'm assuming that you are just trying to set
the active document as shown in my sample below.

2. Generally you either want to Optimize, or to Backtest. Not clear
why you are trying to do both.

The following .ps file works, runs all 100 optimizations. Your sample
probably does to, but then immediately clobbers the result with a
single backtest!

Mike

database = "C:\\Program Files\\Amibroker\ \Data";
formula_1 = "C:\\Simple MA Cross.afl";

AB = new ActiveXObject( "Broker.Application " );
AA = AB.Analysis;

AB.LoadDatabase( database );
AB.ActiveDocument. Name = "^DJI"; // Set ^DJI as active
document

AA.LoadFormula( formula_1 ); // load formula from
external file

AA.ApplyTo = 1; // use current symbol
AA.RangeMode = 3; // use 'From' and 'To' dates
AA.RangeFromDate = "11/01/2005" ;
AA.RangeToDate = "12/31/2005" ;
AA.Optimize( 0 ); // run Optimize for the
portfolio, which is just one symbol

--- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@xx .> wrote:
>
> To add to my confusion, sometimes the below code does produce syntax
> errors when applied. Other times it runs smoothly (albeit with a
> single optimization step). I'm not doing anything different, so I
have
> no idea why it fluctuates.
>
>
> --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> >
> > The simplified code below runs without any syntax error. However,
> > instead of optimizing through all 100 steps, it only does a single
step.
> > Any idea why doesn't it do all 100 steps, as coded in the Simple
MA
> > Cross afl?:
> >
> >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > ------
> > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > ------
> >
> > EnableScript( "jscript" );
> > <%
> >
> > database = "C:\\Program Files\\Amibroker\ \Data";
> > formula_1 = "C:\\Simple MA Cross.afl";
> >
> > AB = new ActiveXObject( "Broker.Application " );
> > AB.LoadDatabase( database );
> > AA = AB.Analysis;
> >
> > AA.LoadFormula( formula_1 ); // load formula from
external
> > file
> >
> > AA.ApplyTo = 1; // use current symbol
> > AA.RangeMode = 3; // use 'From' and 'To'
dates
> > AA.RangeFromDate = "11/01/2005" ;
> > AA.RangeToDate = "12/31/2005" ;
> > AA.Optimize( 0 ); // run Optimize for the
> > portfolio, which is just one symbol
> > //AA.Backtest( );
> >
> > %>
> > //---------END AUTOMATION
> > AFL--------- --------- --------- --------- --------- ----
> >
> >
> >
> > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > >
> > > Hoping someone can chime in here to let me know what I might be
doing
> > > wrong. I'm currently testing out some simple automation code.
The
> > > objective is to load an AFL and then run a portfolio
optimization for
> > a
> > > specified date range.
> > >
> > > I am using a simple MA crossover trading system for testing
purposes.
> > I
> > > can of course optimize it manually in AA without any problem.
But when
> > I
> > > try to run and control that optimization from a piece of
automation
> > > code, I get a whole range of syntax errors.
> > >
> > > Below are the two *separate* AFL codes. I imagine the first AFL
has
> > some
> > > errors in it that is preventing the actions from being carried
out
> > > properly. What am I missing or doing wrong? Any input much
> > appreciated:
> > >
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > ------
> > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > ------
> > >
> > > EnableScript( "jscript" );
> > > <%
> > >
> > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > formula_1 = "C:\\Simple MA Cross.afl";
> > >
> > > AB = new ActiveXObject( "Broker.Application " );
> > > AB.LoadDatabase( database );
> > > AA = AB.Analysis;
> > > Stk = AB.Stocks
> > > Doc = AB.Documents. Open( Stk.Ticker );
> > >
> > > AA.LoadFormula( formula_1 ); // load formula from
> > external
> > > file
> > >
> > > AA.ApplyTo = 1; // use current symbol
> > > AA.RangeMode = 3; // use 'From' and 'To'
dates
> > > AA.RangeFromDate = "11/01/2005" ;
> > > AA.RangeToDate = "12/31/2005" ;
> > > AA.Optimize( 0 ); // run Optimize for
the
> > > portfolio, which is just one symbol
> > > AA.Backtest( );
> > >
> > > %>
> > > //---------END AUTOMATION
> > > AFL--------- --------- --------- --------- --------- ----
> > >
> > >
> > >
> > >
> > >
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > ------
> > > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple
MA
> > > Cross.afl"
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > ------
> > >
> > >
> > > FastMALength = Optimize("FastMALen gth", 1, 1, 100,
1);
> > > SlowMALength = 20;
> > >
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > ------
> > > // BACKTESTER SETTINGS
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > ------
> > >
> > > SetBarsRequired( 10000, 0);
> > > SetOption("AllowPos itionShrinking" , False);
> > > SetOption("AllowSam eBarExit" , True);
> > > SetOption("Commissi onAmount" , 3.00);
> > > SetOption("Commissi onMode", 3);
> > > SetOption("FuturesM ode", 1);
> > > SetOption("InitialE quity", 100000);
> > > SetOption("Interest Rate",0);
> > > SetOption("MaxOpenP ositions" , 1);
> > > SetOption("MinPosVa lue", 0);
> > > SetOption("MinShare s", 1);
> > > SetOption("PriceBou ndChecking" , False );
> > > SetOption("ReverseS ignalForcesExit" , False);
> > > SetOption("UsePrevB arEquityForPosSi zing", True );
> > > SetTradeDelays( 0, 0, 0, 0);
> > > SetPositionSize( 1, spsShares);
> > > TickSize = 0.0001; // The minimum price move of symbol
for
> > Forex
> > > PointValue = 100000;
> > > RoundLotSize = 1;
> > > MarginDeposit = 2500;
> > > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> > >
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > --
> > > // TRADING SYSTEM
> > >
> >
> //---------- --------- --------- --------- --------- --------- ---
----\
> > \
> > > --
> > >
> > > FastMA = MA( C, FastMALength );
> > > SlowMA = MA( C, SlowMALength );
> > > Buy = Cross( FastMA, SlowMA );
> > > Sell = Cross( SlowMA, FastMA );
> > >
> >
>

1e.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "Mike" sfclimbers@xxxxxxcom   sfclimbers

Thu Dec 18, 2008 6:34 pm (PST)

Sorry, that should have read "The following .js file works...".

Mike

--- In amibroker@xxxxxxxxx ps.com, "Mike" <sfclimbers@ ...> wrote:
>
> Are you particularly looking to run the first script from AmiBroker?
> Since the whole thing is intended to just be a batch starter, you
can
> just write it as a vanilla JScript file and run it directly from the
> command line.
>
> Just rename it to have a .js file extension (e.g. runami.js) then
run
> it from the command line using:
>
> wscript runami.js
>
> That being said. There are a few issues with your original post.
> 1. It's not clear what you are trying to do with the Stocks object
and
> your usage of Document. I'm assuming that you are just trying to set
> the active document as shown in my sample below.
>
> 2. Generally you either want to Optimize, or to Backtest. Not clear
> why you are trying to do both.
>
> The following .ps file works, runs all 100 optimizations. Your
sample
> probably does to, but then immediately clobbers the result with a
> single backtest!
>
> Mike
>
>
> database = "C:\\Program Files\\Amibroker\ \Data";
> formula_1 = "C:\\Simple MA Cross.afl";
>
> AB = new ActiveXObject( "Broker.Application " );
> AA = AB.Analysis;
>
> AB.LoadDatabase( database );
> AB.ActiveDocument. Name = "^DJI"; // Set ^DJI as active
> document
>
> AA.LoadFormula( formula_1 ); // load formula from
> external file
>
> AA.ApplyTo = 1; // use current symbol
> AA.RangeMode = 3; // use 'From' and 'To'
dates
> AA.RangeFromDate = "11/01/2005" ;
> AA.RangeToDate = "12/31/2005" ;
> AA.Optimize( 0 ); // run Optimize for the
> portfolio, which is just one symbol
>
>
> --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> >
> > To add to my confusion, sometimes the below code does produce
syntax
> > errors when applied. Other times it runs smoothly (albeit with a
> > single optimization step). I'm not doing anything different, so I
> have
> > no idea why it fluctuates.
> >
> >
> > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > >
> > > The simplified code below runs without any syntax error.
However,
> > > instead of optimizing through all 100 steps, it only does a
single
> step.
> > > Any idea why doesn't it do all 100 steps, as coded in the Simple
> MA
> > > Cross afl?:
> > >
> > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > ------
> > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > ------
> > >
> > > EnableScript( "jscript" );
> > > <%
> > >
> > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > formula_1 = "C:\\Simple MA Cross.afl";
> > >
> > > AB = new ActiveXObject( "Broker.Application " );
> > > AB.LoadDatabase( database );
> > > AA = AB.Analysis;
> > >
> > > AA.LoadFormula( formula_1 ); // load formula from
> external
> > > file
> > >
> > > AA.ApplyTo = 1; // use current symbol
> > > AA.RangeMode = 3; // use 'From' and 'To'
> dates
> > > AA.RangeFromDate = "11/01/2005" ;
> > > AA.RangeToDate = "12/31/2005" ;
> > > AA.Optimize( 0 ); // run Optimize for
the
> > > portfolio, which is just one symbol
> > > //AA.Backtest( );
> > >
> > > %>
> > > //---------END AUTOMATION
> > > AFL--------- --------- --------- --------- --------- ----
> > >
> > >
> > >
> > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@>
wrote:
> > > >
> > > > Hoping someone can chime in here to let me know what I might
be
> doing
> > > > wrong. I'm currently testing out some simple automation code.
> The
> > > > objective is to load an AFL and then run a portfolio
> optimization for
> > > a
> > > > specified date range.
> > > >
> > > > I am using a simple MA crossover trading system for testing
> purposes.
> > > I
> > > > can of course optimize it manually in AA without any problem.
> But when
> > > I
> > > > try to run and control that optimization from a piece of
> automation
> > > > code, I get a whole range of syntax errors.
> > > >
> > > > Below are the two *separate* AFL codes. I imagine the first
AFL
> has
> > > some
> > > > errors in it that is preventing the actions from being carried
> out
> > > > properly. What am I missing or doing wrong? Any input much
> > > appreciated:
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > ------
> > > > // AUTOMATION CODE: Load an AFL and Run a Portfolio
Optimization
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > ------
> > > >
> > > > EnableScript( "jscript" );
> > > > <%
> > > >
> > > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > > formula_1 = "C:\\Simple MA Cross.afl";
> > > >
> > > > AB = new ActiveXObject( "Broker.Application " );
> > > > AB.LoadDatabase( database );
> > > > AA = AB.Analysis;
> > > > Stk = AB.Stocks
> > > > Doc = AB.Documents. Open( Stk.Ticker );
> > > >
> > > > AA.LoadFormula( formula_1 ); // load formula from
> > > external
> > > > file
> > > >
> > > > AA.ApplyTo = 1; // use current
symbol
> > > > AA.RangeMode = 3; // use 'From' and
'To'
> dates
> > > > AA.RangeFromDate = "11/01/2005" ;
> > > > AA.RangeToDate = "12/31/2005" ;
> > > > AA.Optimize( 0 ); // run Optimize for
> the
> > > > portfolio, which is just one symbol
> > > > AA.Backtest( );
> > > >
> > > > %>
> > > > //---------END AUTOMATION
> > > > AFL--------- --------- --------- --------- --------- ----
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > ------
> > > > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT:
"C:\\Simple
> MA
> > > > Cross.afl"
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > ------
> > > >
> > > >
> > > > FastMALength = Optimize("FastMALen gth", 1, 1, 100,
> 1);
> > > > SlowMALength = 20;
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > ------
> > > > // BACKTESTER SETTINGS
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > ------
> > > >
> > > > SetBarsRequired( 10000, 0);
> > > > SetOption("AllowPos itionShrinking" , False);
> > > > SetOption("AllowSam eBarExit" , True);
> > > > SetOption("Commissi onAmount" , 3.00);
> > > > SetOption("Commissi onMode", 3);
> > > > SetOption("FuturesM ode", 1);
> > > > SetOption("InitialE quity", 100000);
> > > > SetOption("Interest Rate",0);
> > > > SetOption("MaxOpenP ositions" , 1);
> > > > SetOption("MinPosVa lue", 0);
> > > > SetOption("MinShare s", 1);
> > > > SetOption("PriceBou ndChecking" , False );
> > > > SetOption("ReverseS ignalForcesExit" , False);
> > > > SetOption("UsePrevB arEquityForPosSi zing", True );
> > > > SetTradeDelays( 0, 0, 0, 0);
> > > > SetPositionSize( 1, spsShares);
> > > > TickSize = 0.0001; // The minimum price move of symbol
> for
> > > Forex
> > > > PointValue = 100000;
> > > > RoundLotSize = 1;
> > > > MarginDeposit = 2500;
> > > > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > --
> > > > // TRADING SYSTEM
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
--
> ----\
> > > \
> > > > --
> > > >
> > > > FastMA = MA( C, FastMALength );
> > > > SlowMA = MA( C, SlowMALength );
> > > > Buy = Cross( FastMA, SlowMA );
> > > > Sell = Cross( SlowMA, FastMA );
> > > >
> > >
> >
>

1f.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "ozzyapeman" zoopfree@xxxxxxxxcom   ozzyapeman

Thu Dec 18, 2008 6:57 pm (PST)

Thanks, Mike. That's a great help.

Yes, there was some junk in my original code. I cobbled it together
from other examples found on this group, and I didn't quite know what
I was doing.

Thanks also for letting me know of the ability to run from the command
line window. I had not even thought of that, or was aware it could
work that way. Do you have any online Jscript tutorials that you could
recommend, specifically geared towards automation? I found some
general purpose tutorials, but want to focus just on automating stuff
like this.

I am still a bit confused why your code runs fine (all 100 opt steps)
when run from the command line, but only does a single opt step when
run as an AFL that simply calls the identical jscript routine.

--- In amibroker@xxxxxxxxx ps.com, "Mike" <sfclimbers@ ...> wrote:
>
> Are you particularly looking to run the first script from AmiBroker?
> Since the whole thing is intended to just be a batch starter, you can
> just write it as a vanilla JScript file and run it directly from the
> command line.
>
> Just rename it to have a .js file extension (e.g. runami.js) then run
> it from the command line using:
>
> wscript runami.js
>
> That being said. There are a few issues with your original post.
> 1. It's not clear what you are trying to do with the Stocks object and
> your usage of Document. I'm assuming that you are just trying to set
> the active document as shown in my sample below.
>
> 2. Generally you either want to Optimize, or to Backtest. Not clear
> why you are trying to do both.
>
> The following .ps file works, runs all 100 optimizations. Your sample
> probably does to, but then immediately clobbers the result with a
> single backtest!
>
> Mike
>
>
> database = "C:\\Program Files\\Amibroker\ \Data";
> formula_1 = "C:\\Simple MA Cross.afl";
>
> AB = new ActiveXObject( "Broker.Application " );
> AA = AB.Analysis;
>
> AB.LoadDatabase( database );
> AB.ActiveDocument. Name = "^DJI"; // Set ^DJI as active
> document
>
> AA.LoadFormula( formula_1 ); // load formula from
> external file
>
> AA.ApplyTo = 1; // use current symbol
> AA.RangeMode = 3; // use 'From' and 'To' dates
> AA.RangeFromDate = "11/01/2005" ;
> AA.RangeToDate = "12/31/2005" ;
> AA.Optimize( 0 ); // run Optimize for the
> portfolio, which is just one symbol
>
>
> --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> >
> > To add to my confusion, sometimes the below code does produce syntax
> > errors when applied. Other times it runs smoothly (albeit with a
> > single optimization step). I'm not doing anything different, so I
> have
> > no idea why it fluctuates.
> >
> >
> > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > >
> > > The simplified code below runs without any syntax error. However,
> > > instead of optimizing through all 100 steps, it only does a single
> step.
> > > Any idea why doesn't it do all 100 steps, as coded in the Simple
> MA
> > > Cross afl?:
> > >
> > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > ------
> > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > ------
> > >
> > > EnableScript( "jscript" );
> > > <%
> > >
> > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > formula_1 = "C:\\Simple MA Cross.afl";
> > >
> > > AB = new ActiveXObject( "Broker.Application " );
> > > AB.LoadDatabase( database );
> > > AA = AB.Analysis;
> > >
> > > AA.LoadFormula( formula_1 ); // load formula from
> external
> > > file
> > >
> > > AA.ApplyTo = 1; // use current symbol
> > > AA.RangeMode = 3; // use 'From' and 'To'
> dates
> > > AA.RangeFromDate = "11/01/2005" ;
> > > AA.RangeToDate = "12/31/2005" ;
> > > AA.Optimize( 0 ); // run Optimize for the
> > > portfolio, which is just one symbol
> > > //AA.Backtest( );
> > >
> > > %>
> > > //---------END AUTOMATION
> > > AFL--------- --------- --------- --------- --------- ----
> > >
> > >
> > >
> > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > > >
> > > > Hoping someone can chime in here to let me know what I might be
> doing
> > > > wrong. I'm currently testing out some simple automation code.
> The
> > > > objective is to load an AFL and then run a portfolio
> optimization for
> > > a
> > > > specified date range.
> > > >
> > > > I am using a simple MA crossover trading system for testing
> purposes.
> > > I
> > > > can of course optimize it manually in AA without any problem.
> But when
> > > I
> > > > try to run and control that optimization from a piece of
> automation
> > > > code, I get a whole range of syntax errors.
> > > >
> > > > Below are the two *separate* AFL codes. I imagine the first AFL
> has
> > > some
> > > > errors in it that is preventing the actions from being carried
> out
> > > > properly. What am I missing or doing wrong? Any input much
> > > appreciated:
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > ------
> > > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > ------
> > > >
> > > > EnableScript( "jscript" );
> > > > <%
> > > >
> > > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > > formula_1 = "C:\\Simple MA Cross.afl";
> > > >
> > > > AB = new ActiveXObject( "Broker.Application " );
> > > > AB.LoadDatabase( database );
> > > > AA = AB.Analysis;
> > > > Stk = AB.Stocks
> > > > Doc = AB.Documents. Open( Stk.Ticker );
> > > >
> > > > AA.LoadFormula( formula_1 ); // load formula from
> > > external
> > > > file
> > > >
> > > > AA.ApplyTo = 1; // use current symbol
> > > > AA.RangeMode = 3; // use 'From' and 'To'
> dates
> > > > AA.RangeFromDate = "11/01/2005" ;
> > > > AA.RangeToDate = "12/31/2005" ;
> > > > AA.Optimize( 0 ); // run Optimize for
> the
> > > > portfolio, which is just one symbol
> > > > AA.Backtest( );
> > > >
> > > > %>
> > > > //---------END AUTOMATION
> > > > AFL--------- --------- --------- --------- --------- ----
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > ------
> > > > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple
> MA
> > > > Cross.afl"
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > ------
> > > >
> > > >
> > > > FastMALength = Optimize("FastMALen gth", 1, 1, 100,

> 1);
> > > > SlowMALength = 20;
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > ------
> > > > // BACKTESTER SETTINGS
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > ------
> > > >
> > > > SetBarsRequired( 10000, 0);
> > > > SetOption("AllowPos itionShrinking" , False);
> > > > SetOption("AllowSam eBarExit" , True);
> > > > SetOption("Commissi onAmount" , 3.00);
> > > > SetOption("Commissi onMode", 3);
> > > > SetOption("FuturesM ode", 1);
> > > > SetOption("InitialE quity", 100000);
> > > > SetOption("Interest Rate",0);
> > > > SetOption("MaxOpenP ositions" , 1);
> > > > SetOption("MinPosVa lue", 0);
> > > > SetOption("MinShare s", 1);
> > > > SetOption("PriceBou ndChecking" , False );
> > > > SetOption("ReverseS ignalForcesExit" , False);
> > > > SetOption("UsePrevB arEquityForPosSi zing", True );
> > > > SetTradeDelays( 0, 0, 0, 0);
> > > > SetPositionSize( 1, spsShares);
> > > > TickSize = 0.0001; // The minimum price move of symbol
> for
> > > Forex
> > > > PointValue = 100000;
> > > > RoundLotSize = 1;
> > > > MarginDeposit = 2500;
> > > > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> > > >
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > --
> > > > // TRADING SYSTEM
> > > >
> > >
> > //---------- --------- --------- --------- --------- --------- ---
> ----\
> > > \
> > > > --
> > > >
> > > > FastMA = MA( C, FastMALength );
> > > > SlowMA = MA( C, SlowMALength );
> > > > Buy = Cross( FastMA, SlowMA );
> > > > Sell = Cross( SlowMA, FastMA );
> > > >
> > >
> >
>

1g.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "dingo" waledingo@xxxxxxcom   dingodigital

Thu Dec 18, 2008 7:07 pm (PST)

you can NOT run optimizations nor backtests from inside an AFL. You MUST run
them from external scripts.

You'd do a whole lot better searching for examples of jscripts in the email
archives here as that is where all of the OLE examples relating to Amibroker
are.

d

On Thu, Dec 18, 2008 at 9:57 PM, ozzyapeman <zoopfree@xxxxxxxx com> wrote:

> Thanks, Mike. That's a great help.
>
> Yes, there was some junk in my original code. I cobbled it together
> from other examples found on this group, and I didn't quite know what
> I was doing.
>
> Thanks also for letting me know of the ability to run from the command
> line window. I had not even thought of that, or was aware it could
> work that way. Do you have any online Jscript tutorials that you could
> recommend, specifically geared towards automation? I found some
> general purpose tutorials, but want to focus just on automating stuff
> like this.
>
> I am still a bit confused why your code runs fine (all 100 opt steps)
> when run from the command line, but only does a single opt step when
> run as an AFL that simply calls the identical jscript routine.
>
>
> --- In amibroker@xxxxxxxxx ps.com, "Mike" <sfclimbers@ ...> wrote:
> >
> > Are you particularly looking to run the first script from AmiBroker?
> > Since the whole thing is intended to just be a batch starter, you can
> > just write it as a vanilla JScript file and run it directly from the
> > command line.
> >
> > Just rename it to have a .js file extension (e.g. runami.js) then run
> > it from the command line using:
> >
> > wscript runami.js
> >
> > That being said. There are a few issues with your original post.
> > 1. It's not clear what you are trying to do with the Stocks object and
> > your usage of Document. I'm assuming that you are just trying to set
> > the active document as shown in my sample below.
> >
> > 2. Generally you either want to Optimize, or to Backtest. Not clear
> > why you are trying to do both.
> >
> > The following .ps file works, runs all 100 optimizations. Your sample
> > probably does to, but then immediately clobbers the result with a
> > single backtest!
> >
> > Mike
> >
> >
> > database = "C:\\Program Files\\Amibroker\ \Data";
> > formula_1 = "C:\\Simple MA Cross.afl";
> >
> > AB = new ActiveXObject( "Broker.Application " );
> > AA = AB.Analysis;
> >
> > AB.LoadDatabase( database );
> > AB.ActiveDocument. Name <http://ab.activedoc ument.name/> = "^DJI";
> // Set ^DJI as active
> > document
> >
> > AA.LoadFormula( formula_1 ); // load formula from
> > external file
> >
> > AA.ApplyTo = 1; // use current symbol
> > AA.RangeMode = 3; // use 'From' and 'To' dates
> > AA.RangeFromDate = "11/01/2005" ;
> > AA.RangeToDate = "12/31/2005" ;
> > AA.Optimize( 0 ); // run Optimize for the
> > portfolio, which is just one symbol
> >
> >
> > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > >
> > > To add to my confusion, sometimes the below code does produce syntax
> > > errors when applied. Other times it runs smoothly (albeit with a
> > > single optimization step). I'm not doing anything different, so I
> > have
> > > no idea why it fluctuates.
> > >
> > >
> > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > > >
> > > > The simplified code below runs without any syntax error. However,
> > > > instead of optimizing through all 100 steps, it only does a single
> > step.
> > > > Any idea why doesn't it do all 100 steps, as coded in the Simple
> > MA
> > > > Cross afl?:
> > > >
> > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > ------
> > > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > ------
> > > >
> > > > EnableScript( "jscript" );
> > > > <%
> > > >
> > > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > > formula_1 = "C:\\Simple MA Cross.afl";
> > > >
> > > > AB = new ActiveXObject( "Broker.Application " );
> > > > AB.LoadDatabase( database );
> > > > AA = AB.Analysis;
> > > >
> > > > AA.LoadFormula( formula_1 ); // load formula from
> > external
> > > > file
> > > >
> > > > AA.ApplyTo = 1; // use current symbol
> > > > AA.RangeMode = 3; // use 'From' and 'To'
> > dates
> > > > AA.RangeFromDate = "11/01/2005" ;
> > > > AA.RangeToDate = "12/31/2005" ;
> > > > AA.Optimize( 0 ); // run Optimize for the
> > > > portfolio, which is just one symbol
> > > > //AA.Backtest( );
> > > >
> > > > %>
> > > > //---------END AUTOMATION
> > > > AFL--------- --------- --------- --------- --------- ----
> > > >
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > > > >
> > > > > Hoping someone can chime in here to let me know what I might be
> > doing
> > > > > wrong. I'm currently testing out some simple automation code.
> > The
> > > > > objective is to load an AFL and then run a portfolio
> > optimization for
> > > > a
> > > > > specified date range.
> > > > >
> > > > > I am using a simple MA crossover trading system for testing
> > purposes.
> > > > I
> > > > > can of course optimize it manually in AA without any problem.
> > But when
> > > > I
> > > > > try to run and control that optimization from a piece of
> > automation
> > > > > code, I get a whole range of syntax errors.
> > > > >
> > > > > Below are the two *separate* AFL codes. I imagine the first AFL
> > has
> > > > some
> > > > > errors in it that is preventing the actions from being carried
> > out
> > > > > properly. What am I missing or doing wrong? Any input much
> > > > appreciated:
> > > > >
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > ------
> > > > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > ------
> > > > >
> > > > > EnableScript( "jscript" );
> > > > > <%
> > > > >
> > > > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > > > formula_1 = "C:\\Simple MA Cross.afl";
> > > > >
> > > > > AB = new ActiveXObject( "Broker.Application " );
> > > > > AB.LoadDatabase( database );
> > > > > AA = AB.Analysis;
> > > > > Stk = AB.Stocks
> > > > > Doc = AB.Documents. Open( Stk.Ticker );
> > > > >
> > > > > AA.LoadFormula( formula_1 ); // load formula from
> > > > external
> > > > > file
> > > > >
> > > > > AA.ApplyTo = 1; // use current symbol
> > > > > AA.RangeMode = 3; // use 'From' and 'To'
> > dates
> > > > > AA.RangeFromDate = "11/01/2005" ;
> > > > > AA.RangeToDate = "12/31/2005" ;
> > > > > AA.Optimize( 0 ); // run Optimize for
> > the
> > > > > portfolio, which is just one symbol
> > > > > AA.Backtest( );
> > > > >
> > > > > %>
> > > > > //---------END AUTOMATION
> > > > > AFL--------- --------- --------- --------- --------- ----
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > ------
> > > > > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple
> > MA
> > > > > Cross.afl"
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > ------
> > > > >
> > > > >
> > > > > FastMALength = Optimize("FastMALen gth", 1, 1, 100,
>
> > 1);
> > > > > SlowMALength = 20;
> > > > >
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > ------
> > > > > // BACKTESTER SETTINGS
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > ------
> > > > >
> > > > > SetBarsRequired( 10000, 0);
> > > > > SetOption("AllowPos itionShrinking" , False);
> > > > > SetOption("AllowSam eBarExit" , True);
> > > > > SetOption("Commissi onAmount" , 3.00);
> > > > > SetOption("Commissi onMode", 3);
> > > > > SetOption("FuturesM ode", 1);
> > > > > SetOption("InitialE quity", 100000);
> > > > > SetOption("Interest Rate",0);
> > > > > SetOption("MaxOpenP ositions" , 1);
> > > > > SetOption("MinPosVa lue", 0);
> > > > > SetOption("MinShare s", 1);
> > > > > SetOption("PriceBou ndChecking" , False );
> > > > > SetOption("ReverseS ignalForcesExit" , False);
> > > > > SetOption("UsePrevB arEquityForPosSi zing", True );
> > > > > SetTradeDelays( 0, 0, 0, 0);
> > > > > SetPositionSize( 1, spsShares);
> > > > > TickSize = 0.0001; // The minimum price move of symbol
> > for
> > > > Forex
> > > > > PointValue = 100000;
> > > > > RoundLotSize = 1;
> > > > > MarginDeposit = 2500;
> > > > > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> > > > >
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > --
> > > > > // TRADING SYSTEM
> > > > >
> > > >
> > > //---------- --------- --------- --------- --------- --------- ---
> > ----\
> > > > \
> > > > > --
> > > > >
> > > > > FastMA = MA( C, FastMALength );
> > > > > SlowMA = MA( C, SlowMALength );
> > > > > Buy = Cross( FastMA, SlowMA );
> > > > > Sell = Cross( SlowMA, FastMA );
> > > > >
> > > >
> > >
> >
>
>
>
> ------------ --------- --------- ------
>
> **** IMPORTANT ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> ************ *********
> TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
> ************ *********
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroke r.com/devlog/
>
> For other support material please check also:
> http://www.amibroke r.com/support. html
>
> ************ ********* ********* ***
> Yahoo! Groups Links
>
>
>
>
1h.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "ozzyapeman" zoopfree@xxxxxxxxcom   ozzyapeman

Thu Dec 18, 2008 7:10 pm (PST)

Ah. Well that explains it then! :-)

Thanks for the heads up. I will look for more jscript examples to try
to get the hang of this automation thing.

--- In amibroker@xxxxxxxxx ps.com, dingo <waledingo@x ..> wrote:
>
> you can NOT run optimizations nor backtests from inside an AFL. You
MUST run
> them from external scripts.
>
> You'd do a whole lot better searching for examples of jscripts in
the email
> archives here as that is where all of the OLE examples relating to
Amibroker
> are.
>
> d
>
> On Thu, Dec 18, 2008 at 9:57 PM, ozzyapeman <zoopfree@xx .> wrote:
>
> > Thanks, Mike. That's a great help.
> >
> > Yes, there was some junk in my original code. I cobbled it together
> > from other examples found on this group, and I didn't quite know what
> > I was doing.
> >
> > Thanks also for letting me know of the ability to run from the command
> > line window. I had not even thought of that, or was aware it could
> > work that way. Do you have any online Jscript tutorials that you could
> > recommend, specifically geared towards automation? I found some
> > general purpose tutorials, but want to focus just on automating stuff
> > like this.
> >
> > I am still a bit confused why your code runs fine (all 100 opt steps)
> > when run from the command line, but only does a single opt step when
> > run as an AFL that simply calls the identical jscript routine.
> >
> >
> > --- In amibroker@xxxxxxxxx ps.com, "Mike" <sfclimbers@ > wrote:
> > >
> > > Are you particularly looking to run the first script from
AmiBroker?
> > > Since the whole thing is intended to just be a batch starter,
you can
> > > just write it as a vanilla JScript file and run it directly from the
> > > command line.
> > >
> > > Just rename it to have a .js file extension (e.g. runami.js)
then run
> > > it from the command line using:
> > >
> > > wscript runami.js
> > >
> > > That being said. There are a few issues with your original post.
> > > 1. It's not clear what you are trying to do with the Stocks
object and
> > > your usage of Document. I'm assuming that you are just trying to set
> > > the active document as shown in my sample below.
> > >
> > > 2. Generally you either want to Optimize, or to Backtest. Not clear
> > > why you are trying to do both.
> > >
> > > The following .ps file works, runs all 100 optimizations. Your
sample
> > > probably does to, but then immediately clobbers the result with a
> > > single backtest!
> > >
> > > Mike
> > >
> > >
> > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > formula_1 = "C:\\Simple MA Cross.afl";
> > >
> > > AB = new ActiveXObject( "Broker.Application " );
> > > AA = AB.Analysis;
> > >
> > > AB.LoadDatabase( database );
> > > AB.ActiveDocument. Name <http://ab.activedoc ument.name/> = "^DJI";
> > // Set ^DJI as active
> > > document
> > >
> > > AA.LoadFormula( formula_1 ); // load formula from
> > > external file
> > >
> > > AA.ApplyTo = 1; // use current symbol
> > > AA.RangeMode = 3; // use 'From' and 'To'
dates
> > > AA.RangeFromDate = "11/01/2005" ;
> > > AA.RangeToDate = "12/31/2005" ;
> > > AA.Optimize( 0 ); // run Optimize for the
> > > portfolio, which is just one symbol
> > >
> > >
> > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > > >
> > > > To add to my confusion, sometimes the below code does produce
syntax
> > > > errors when applied. Other times it runs smoothly (albeit with a
> > > > single optimization step). I'm not doing anything different, so I
> > > have
> > > > no idea why it fluctuates.
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@> wrote:
> > > > >
> > > > > The simplified code below runs without any syntax error.
However,
> > > > > instead of optimizing through all 100 steps, it only does a
single
> > > step.
> > > > > Any idea why doesn't it do all 100 steps, as coded in the Simple
> > > MA
> > > > > Cross afl?:
> > > > >
> > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > ------
> > > > > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > ------
> > > > >
> > > > > EnableScript( "jscript" );
> > > > > <%
> > > > >
> > > > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > > > formula_1 = "C:\\Simple MA Cross.afl";
> > > > >
> > > > > AB = new ActiveXObject( "Broker.Application " );
> > > > > AB.LoadDatabase( database );
> > > > > AA = AB.Analysis;
> > > > >
> > > > > AA.LoadFormula( formula_1 ); // load formula from
> > > external
> > > > > file
> > > > >
> > > > > AA.ApplyTo = 1; // use current symbol
> > > > > AA.RangeMode = 3; // use 'From' and 'To'
> > > dates
> > > > > AA.RangeFromDate = "11/01/2005" ;
> > > > > AA.RangeToDate = "12/31/2005" ;
> > > > > AA.Optimize( 0 ); // run Optimize
for the
> > > > > portfolio, which is just one symbol
> > > > > //AA.Backtest( );
> > > > >
> > > > > %>
> > > > > //---------END AUTOMATION
> > > > > AFL--------- --------- --------- --------- --------- ----
> > > > >
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@>
wrote:
> > > > > >
> > > > > > Hoping someone can chime in here to let me know what I
might be
> > > doing
> > > > > > wrong. I'm currently testing out some simple automation code.
> > > The
> > > > > > objective is to load an AFL and then run a portfolio
> > > optimization for
> > > > > a
> > > > > > specified date range.
> > > > > >
> > > > > > I am using a simple MA crossover trading system for testing
> > > purposes.
> > > > > I
> > > > > > can of course optimize it manually in AA without any problem.
> > > But when
> > > > > I
> > > > > > try to run and control that optimization from a piece of
> > > automation
> > > > > > code, I get a whole range of syntax errors.
> > > > > >
> > > > > > Below are the two *separate* AFL codes. I imagine the
first AFL
> > > has
> > > > > some
> > > > > > errors in it that is preventing the actions from being carried
> > > out
> > > > > > properly. What am I missing or doing wrong? Any input much
> > > > > appreciated:
> > > > > >
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > ------
> > > > > > // AUTOMATION CODE: Load an AFL and Run a Portfolio
Optimization
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > ------
> > > > > >
> > > > > > EnableScript( "jscript" );
> > > > > > <%
> > > > > >
> > > > > > database = "C:\\Program Files\\Amibroker\ \Data";
> > > > > > formula_1 = "C:\\Simple MA Cross.afl";
> > > > > >
> > > > > > AB = new ActiveXObject( "Broker.Application " );
> > > > > > AB.LoadDatabase( database );
> > > > > > AA = AB.Analysis;
> > > > > > Stk = AB.Stocks
> > > > > > Doc = AB.Documents. Open( Stk.Ticker );
> > > > > >
> > > > > > AA.LoadFormula( formula_1 ); // load formula from
> > > > > external
> > > > > > file
> > > > > >
> > > > > > AA.ApplyTo = 1; // use current
symbol
> > > > > > AA.RangeMode = 3; // use 'From'
and 'To'
> > > dates
> > > > > > AA.RangeFromDate = "11/01/2005" ;
> > > > > > AA.RangeToDate = "12/31/2005" ;
> > > > > > AA.Optimize( 0 ); // run Optimize for
> > > the
> > > > > > portfolio, which is just one symbol
> > > > > > AA.Backtest( );
> > > > > >
> > > > > > %>
> > > > > > //---------END AUTOMATION
> > > > > > AFL--------- --------- --------- --------- --------- ----
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > ------
> > > > > > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT:
"C:\\Simple
> > > MA
> > > > > > Cross.afl"
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > ------
> > > > > >
> > > > > >
> > > > > > FastMALength = Optimize("FastMALen gth", 1, 1, 100,
> >
> > > 1);
> > > > > > SlowMALength = 20;
> > > > > >
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > ------
> > > > > > // BACKTESTER SETTINGS
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > ------
> > > > > >
> > > > > > SetBarsRequired( 10000, 0);
> > > > > > SetOption("AllowPos itionShrinking" , False);
> > > > > > SetOption("AllowSam eBarExit" , True);
> > > > > > SetOption("Commissi onAmount" , 3.00);
> > > > > > SetOption("Commissi onMode", 3);
> > > > > > SetOption("FuturesM ode", 1);
> > > > > > SetOption("InitialE quity", 100000);
> > > > > > SetOption("Interest Rate",0);
> > > > > > SetOption("MaxOpenP ositions" , 1);
> > > > > > SetOption("MinPosVa lue", 0);
> > > > > > SetOption("MinShare s", 1);
> > > > > > SetOption("PriceBou ndChecking" , False );
> > > > > > SetOption("ReverseS ignalForcesExit" , False);
> > > > > > SetOption("UsePrevB arEquityForPosSi zing", True );
> > > > > > SetTradeDelays( 0, 0, 0, 0);
> > > > > > SetPositionSize( 1, spsShares);
> > > > > > TickSize = 0.0001; // The minimum price move of symbol
> > > for
> > > > > Forex
> > > > > > PointValue = 100000;
> > > > > > RoundLotSize = 1;
> > > > > > MarginDeposit = 2500;
> > > > > > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> > > > > >
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > --
> > > > > > // TRADING SYSTEM
> > > > > >
> > > > >
> > > >
//---------- --------- --------- --------- --------- --------- ---
> > > ----\
> > > > > \
> > > > > > --
> > > > > >
> > > > > > FastMA = MA( C, FastMALength );
> > > > > > SlowMA = MA( C, SlowMALength );
> > > > > > Buy = Cross( FastMA, SlowMA );
> > > > > > Sell = Cross( SlowMA, FastMA );
> > > > > >
> > > > >
> > > >
> > >
> >
> >
> >
> > ------------ --------- --------- ------
> >
> > **** IMPORTANT ****
> > This group is for the discussion between users only.
> > This is *NOT* technical support channel.
> >
> > ************ *********
> > TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail
directly to
> > SUPPORT {at} amibroker.com
> > ************ *********
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroke r.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroke r.com/support. html
> >
> > ************ ********* ********* ***
> > Yahoo! Groups Links
> >
> >
> >
> >
>

1i.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "Paul Ho" paul.tsho@xxxxxxcom   paultsho

Fri Dec 19, 2008 1:39 am (PST)

YOu cant run automation that controls optimization from within an afl. Do it
with jscript outside AB.

_____

From: amibroker@xxxxxxxxx ps.com [mailto:amibroker@xxxxxxxxx ps.com] On Behalf
Of ozzyapeman
Sent: Friday, 19 December 2008 1:18 PM
To: amibroker@xxxxxxxxx ps.com
Subject: [amibroker] Re: Automation to load an AFL and run Portfolio
Optimization

To add to my confusion, sometimes the below code does produce syntax
errors when applied. Other times it runs smoothly (albeit with a
single optimization step). I'm not doing anything different, so I have
no idea why it fluctuates.

--- In amibroker@xxxxxxxxx <mailto:amibroker% 40yahoogroups. com> ps.com,
"ozzyapeman" <zoopfree@xx .> wrote:
>
> The simplified code below runs without any syntax error. However,
> instead of optimizing through all 100 steps, it only does a single step.
> Any idea why doesn't it do all 100 steps, as coded in the Simple MA
> Cross afl?:
>
>
>
//---------- --------- --------- --------- --------- --------- ---\
> ------
> // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
>
//---------- --------- --------- --------- --------- --------- ---\
> ------
>
> EnableScript( "jscript" );
> <%
>
> database = "C:\\Program Files\\Amibroker\ \Data";
> formula_1 = "C:\\Simple MA Cross.afl";
>
> AB = new ActiveXObject( "Broker.Application " );
> AB.LoadDatabase( database );
> AA = AB.Analysis;
>
> AA.LoadFormula( formula_1 ); // load formula from external
> file
>
> AA.ApplyTo = 1; // use current symbol
> AA.RangeMode = 3; // use 'From' and 'To' dates
> AA.RangeFromDate = "11/01/2005" ;
> AA.RangeToDate = "12/31/2005" ;
> AA.Optimize( 0 ); // run Optimize for the
> portfolio, which is just one symbol
> //AA.Backtest( );
>
> %>
> //---------END AUTOMATION
> AFL--------- --------- --------- --------- --------- ----
>
>
>
> --- In amibroker@xxxxxxxxx <mailto:amibroker% 40yahoogroups. com> ps.com,
"ozzyapeman" <zoopfree@> wrote:
> >
> > Hoping someone can chime in here to let me know what I might be doing
> > wrong. I'm currently testing out some simple automation code. The
> > objective is to load an AFL and then run a portfolio optimization for
> a
> > specified date range.
> >
> > I am using a simple MA crossover trading system for testing purposes.
> I
> > can of course optimize it manually in AA without any problem. But when
> I
> > try to run and control that optimization from a piece of automation
> > code, I get a whole range of syntax errors.
> >
> > Below are the two *separate* AFL codes. I imagine the first AFL has
> some
> > errors in it that is preventing the actions from being carried out
> > properly. What am I missing or doing wrong? Any input much
> appreciated:
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> > // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> >
> > EnableScript( "jscript" );
> > <%
> >
> > database = "C:\\Program Files\\Amibroker\ \Data";
> > formula_1 = "C:\\Simple MA Cross.afl";
> >
> > AB = new ActiveXObject( "Broker.Application " );
> > AB.LoadDatabase( database );
> > AA = AB.Analysis;
> > Stk = AB.Stocks
> > Doc = AB.Documents. Open( Stk.Ticker );
> >
> > AA.LoadFormula( formula_1 ); // load formula from
> external
> > file
> >
> > AA.ApplyTo = 1; // use current symbol
> > AA.RangeMode = 3; // use 'From' and 'To' dates
> > AA.RangeFromDate = "11/01/2005" ;
> > AA.RangeToDate = "12/31/2005" ;
> > AA.Optimize( 0 ); // run Optimize for the
> > portfolio, which is just one symbol
> > AA.Backtest( );
> >
> > %>
> > //---------END AUTOMATION
> > AFL--------- --------- --------- --------- --------- ----
> >
> >
> >
> >
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> > // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple MA
> > Cross.afl"
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> >
> >
> > FastMALength = Optimize("FastMALen gth", 1, 1, 100, 1);
> > SlowMALength = 20;
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> > // BACKTESTER SETTINGS
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > ------
> >
> > SetBarsRequired( 10000, 0);
> > SetOption("AllowPos itionShrinking" , False);
> > SetOption("AllowSam eBarExit" , True);
> > SetOption("Commissi onAmount" , 3.00);
> > SetOption("Commissi onMode", 3);
> > SetOption("FuturesM ode", 1);
> > SetOption("InitialE quity", 100000);
> > SetOption("Interest Rate",0);
> > SetOption("MaxOpenP ositions" , 1);
> > SetOption("MinPosVa lue", 0);
> > SetOption("MinShare s", 1);
> > SetOption("PriceBou ndChecking" , False );
> > SetOption("ReverseS ignalForcesExit" , False);
> > SetOption("UsePrevB arEquityForPosSi zing", True );
> > SetTradeDelays( 0, 0, 0, 0);
> > SetPositionSize( 1, spsShares);
> > TickSize = 0.0001; // The minimum price move of symbol for
> Forex
> > PointValue = 100000;
> > RoundLotSize = 1;
> > MarginDeposit = 2500;
> > BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
> >
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > --
> > // TRADING SYSTEM
> >
>
//---------- --------- --------- --------- --------- --------- ---\
> \
> > --
> >
> > FastMA = MA( C, FastMALength );
> > SlowMA = MA( C, SlowMALength );
> > Buy = Cross( FastMA, SlowMA );
> > Sell = Cross( SlowMA, FastMA );
> >
>

1j.

Re: Automation to load an AFL and run Portfolio Optimization

Posted by: "Tomasz Janeczko" groups@xxxxxxxxxxcom   amibroker

Fri Dec 19, 2008 1:59 am (PST)

You can only automate AA from OUTSIDE of AA.

I.e. the script should be EXTERNAL JScript, not an AFL run from AA befcause it will be
immediatelly overwritten in first iteration.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: ozzyapeman
To: amibroker@xxxxxxxxx ps.com
Sent: Friday, December 19, 2008 3:12 AM
Subject: [amibroker] Re: Automation to load an AFL and run Portfolio Optimization

The simplified code below runs without any syntax error. However, instead of optimizing through all 100 steps, it only does a single step. Any idea why doesn't it do all 100 steps, as coded in the Simple MA Cross afl?:

//---------- --------- --------- --------- --------- --------- ---
// AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
//---------- --------- --------- --------- --------- --------- ---

EnableScript( "jscript" );
<%

database = "C:\\Program Files\\Amibroker\ \Data";
formula_1 = "C:\\Simple MA Cross.afl";

AB = new ActiveXObject( "Broker.Application " );
AB.LoadDatabase( database );
AA = AB.Analysis;

AA.LoadFormula( formula_1 ); // load formula from external file

AA.ApplyTo = 1; // use current symbol
AA.RangeMode = 3; // use 'From' and 'To' dates
AA.RangeFromDate = "11/01/2005" ;
AA.RangeToDate = "12/31/2005" ;
AA.Optimize( 0 ); // run Optimize for the portfolio, which is just one symbol
//AA.Backtest( );

%>
//---------END AUTOMATION AFL--------- --------- --------- --------- --------- ----

--- In amibroker@xxxxxxxxx ps.com, "ozzyapeman" <zoopfree@xx .> wrote:
>
> Hoping someone can chime in here to let me know what I might be doing
> wrong. I'm currently testing out some simple automation code. The
> objective is to load an AFL and then run a portfolio optimization for a
> specified date range.
>
> I am using a simple MA crossover trading system for testing purposes. I
> can of course optimize it manually in AA without any problem. But when I
> try to run and control that optimization from a piece of automation
> code, I get a whole range of syntax errors.
>
> Below are the two *separate* AFL codes. I imagine the first AFL has some
> errors in it that is preventing the actions from being carried out
> properly. What am I missing or doing wrong? Any input much appreciated:
>
> //---------- --------- --------- --------- --------- --------- ---\
> ------
> // AUTOMATION CODE: Load an AFL and Run a Portfolio Optimization
> //---------- --------- --------- --------- --------- --------- ---\
> ------
>
> EnableScript( "jscript" );
> <%
>
> database = "C:\\Program Files\\Amibroker\ \Data";
> formula_1 = "C:\\Simple MA Cross.afl";
>
> AB = new ActiveXObject( "Broker.Application " );
> AB.LoadDatabase( database );
> AA = AB.Analysis;
> Stk = AB.Stocks
> Doc = AB.Documents. Open( Stk.Ticker );
>
> AA.LoadFormula( formula_1 ); // load formula from external
> file
>
> AA.ApplyTo = 1; // use current symbol
> AA.RangeMode = 3; // use 'From' and 'To' dates
> AA.RangeFromDate = "11/01/2005" ;
> AA.RangeToDate = "12/31/2005" ;
> AA.Optimize( 0 ); // run Optimize for the
> portfolio, which is just one symbol
> AA.Backtest( );
>
> %>
> //---------END AUTOMATION
> AFL--------- --------- --------- --------- --------- ----
>
>
>
>
>
> //---------- --------- --------- --------- --------- --------- ---\
> ------
> // Simple MA Cross: THIS IS A SEPARATE AFL SAVED AT: "C:\\Simple MA
> Cross.afl"
> //---------- --------- --------- --------- --------- --------- ---\
> ------
>
>
> FastMALength = Optimize("FastMALen gth", 1, 1, 100, 1);
> SlowMALength = 20;
>
> //---------- --------- --------- --------- --------- --------- ---\
> ------
> // BACKTESTER SETTINGS
> //---------- --------- --------- --------- --------- --------- ---\
> ------
>
> SetBarsRequired( 10000, 0);
> SetOption("AllowPos itionShrinking" , False);
> SetOption("AllowSam eBarExit" , True);
> SetOption("Commissi onAmount" , 3.00);
> SetOption("Commissi onMode", 3);
> SetOption("FuturesM ode", 1);
> SetOption("InitialE quity", 100000);
> SetOption("Interest Rate",0);
> SetOption("MaxOpenP ositions" , 1);
> SetOption("MinPosVa lue", 0);
> SetOption("MinShare s", 1);
> SetOption("PriceBou ndChecking" , False );
> SetOption("ReverseS ignalForcesExit" , False);
> SetOption("UsePrevB arEquityForPosSi zing", True );
> SetTradeDelays( 0, 0, 0, 0);
> SetPositionSize( 1, spsShares);
> TickSize = 0.0001; // The minimum price move of symbol for Forex
> PointValue = 100000;
> RoundLotSize = 1;
> MarginDeposit = 2500;
> BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
>
> //---------- --------- --------- --------- --------- --------- ---\
> --
> // TRADING SYSTEM
> //---------- --------- --------- --------- --------- --------- ---\
> --
>
> FastMA = MA( C, FastMALength );
> SlowMA = MA( C, SlowMALength );
> Buy = Cross( FastMA, SlowMA );
> Sell = Cross( SlowMA, FastMA );
>
2a.

Re: scrolling through a watchlist

Posted by: "Mike" sfclimbers@xxxxxxcom   sfclimbers

Thu Dec 18, 2008 6:00 pm (PST)

My last post seems to have been lost.
To summarize, make sure that the following line is present and does
not have any embedded spaces between the quotes. Yahoo tends to stuff
in extra blank spaces into these posts.

ab = CreateObject( "Broker.Applicat ion");

Mike

--- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...> wrote:
>
> When I put the beginning of that script in I get messages like:
> COM/object handle is null
> COM object variable is not initialized or has invalid type.
> Its highlighting both the aa = line and the wl= line.
> Am i doing something wrong by just putting it in there?
> is there another way to get the active watchlist number? Cuz that
way I could
> just select all in the AA and through the code get the active
watchlist number and extract the symbols from there. I just dont know
how to get the active watchlist number of the symbol being analyzed.
>
>
> --- On Thu, 12/18/08, Mike <sfclimbers@ ...> wrote:
> From: Mike <sfclimbers@ ...>
> Subject: [amibroker] Re: scrolling through a watchlist
> To: amibroker@xxxxxxxxx ps.com
> Date: Thursday, December 18, 2008, 3:48 PM
>
>
>
>
>
>
>
>
>
>
>
> Just make any number of watchlists that you want, each
with exactly
>
> two symbols. Then, select whichever list you want to work against in
>
> the AA window and run the following script. Select a different
>
> watchlist in the AA window and run the script again. Repeat for as
>
> many lists as you have.
>
>
>
> There may be a cleaner way for getting the active watchlist. But the
>
> method used should work.
>
>
>
> Mike
>
>
>
> --
>
> Buy = Sell = 0;
>
>
>
> ab = CreateObject( "Broker.Applicat ion");
>
> aa = ab.Analysis;
>
> wl = aa.Filter(0, "watchlist") ;
>
>
>
> list = CategoryGetSymbols( categoryWatchlis t, wl);
>
> ticker1 = StrExtract(list, 0);
>
> ticker2 = StrExtract(list, 1);
>
>
>
> _TRACE(CategoryGetN ame(categoryWatc hlist, wl) + ": " + ticker1 + "
>
> and " + ticker2);
>
>
>
> if (Name() == ticker1) {
>
> SetForeign(ticker2) ;
>
> // Read whatever you want from second data, e.g.
>
> foreignClose = Close;
>
> RestorePriceArrays( );
>
>
>
> Buy = foreignClose > Close;
>
> Sell = foreignClose < Close;
>
> }
>
>
>
> if (Name() == ticker2) {
>
> SetForeign(ticker1) ;
>
> // Read whatever you want from first data, e.g.
>
> foreignHigh = High;
>
> RestorePriceArrays( );
>
>
>
> Buy = foreignHigh > High;
>
> Sell = foreignHigh < High;
>
> }
>
>
>
> --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
wrote:
>
> >
>
> > Your totally right actually. As long as the list is finite that
>
> should be fine. Im such a newbie at this coding though so the
>
> simplest things are difficult.
>
> > How do I say:
>
> > If current ticker belongs to watchlist1, then ticker1=F and
>
> ticker2=GM.
>
> >
>
> > Ticker1 and Ticker2 are parts of my code. Then I figure I do it
>
> this way. Next writing if current ticker belongs to watchlist2
>
> then ....
>
> > Then I run the code. I think that way would be the best.
>
> >
>
> > --- On Wed, 12/17/08, Mike <sfclimbers@ ...> wrote:
>
> > From: Mike <sfclimbers@ ...>
>
> > Subject: [amibroker] Re: scrolling through a watchlist
>
> > To: amibroker@xxxxxxxxx ps.com
>
> > Date: Wednesday, December 17, 2008, 11:57 PM
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > What's wrong with the "both symbols in a single list"
>
> approach? I
>
> >
>
> > believe that the assumption is that you would have multiple lists,
>
> >
>
> > each with exactly two symbols (as you had originally suggested).
>
> Where
>
> >
>
> > are you running into problems?
>
> >
>
> >
>
> >
>
> > If it's a case of the script logic not being applicable from one
>
> pair
>
> >
>
> > to the next, then the whole hard coding of names problem goes away
>
> >
>
> > because each script would be customized to a pair and you could
>
> hard
>
> >
>
> > code the names after all, as per Tomasz's example. Otherwise, were
>
> you
>
> >
>
> > not able to dig out the names correctly using StrExtract?
>
> >
>
> >
>
> >
>
> > Mike
>
> >
>
> >
>
> >
>
> > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
>
> wrote:
>
> >
>
> > >
>
> >
>
> > > Ya that code isn't working very well. Also all the 1st part of
>
> the
>
> >
>
> > pairs in one watchlists and the seconds in a second list can't
>
> really
>
> >
>
> > work because its alphabetizing each list. So when I enter the
>
> orders
>
> >
>
> > for the first list its fine, but then I get to the second list and
>
> it
>
> >
>
> > alphabetizes that so it ruins the order with the first list. This
>
> is
>
> >
>
> > tough man!
>
> >
>
> > >
>
> >
>
> > > --- On Mon, 12/15/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > > From: Mike <sfclimbers@ ...>
>
> >
>
> > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > > Date: Monday, December 15, 2008, 8:21 PM
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Hi,
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Sorry, it was not clear that you were wanting to act on both
>
> >
>
> > symbols.
>
> >
>
> > >
>
> >
>
> > > I thought you were trying to buy from the first list only, based
>
> on
>
> >
>
> > >
>
> >
>
> > > signals/confirmatio n from the second list.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > As you've now discovered, the Foreign functionality allows
access
>
> to
>
> >
>
> > >
>
> >
>
> > > foreign data, but it does not allow you to generate signals for
>
> that
>
> >
>
> > >
>
> >
>
> > > foreign symbol. To act on the symbol, it must appear in the
>
> >
>
> > watchlist
>
> >
>
> > >
>
> >
>
> > > and be processed in turn.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Tomasz has answered your question, which is the route that you
>
> were
>
> >
>
> > >
>
> >
>
> > > originally heading down. But, he did not address the hard coded
>
> >
>
> > names
>
> >
>
> > >
>
> >
>
> > > that you were trying to avoid.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > To avoid the hard coded names of Tomasz's answer, Dingo gave you
>
> the
>
> >
>
> > >
>
> >
>
> > > answer, which is also what I used in my earlier sample.
>
> >
>
> > Specifically;
>
> >
>
> > >
>
> >
>
> > > use StrExtract from the watchlist.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Putting it all togeather...
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Again the symbols will be evaluated in alphabetical order, but
>
> >
>
> > >
>
> >
>
> > > CategoryGetSymbols will give the ordering as they appear in the
>
> >
>
> > >
>
> >
>
> > > watchlist (i.e. not necessarily alphabetized) . So, if it
>
> matters,
>
> >
>
> > >
>
> >
>
> > > populate your list such that the symbol you want to to be
treated
>
> as
>
> >
>
> > >
>
> >
>
> > > first actually appears first in the watchlist, even though the
>
> >
>
> > second
>
> >
>
> > >
>
> >
>
> > > may get run through the script before the first one.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Buy = Sell = Short = Cover = 0;
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > list = CategoryGetSymbols( categoryWatchlis t, 1);
>
> >
>
> > >
>
> >
>
> > > first = StrExtract(list, 0);
>
> >
>
> > >
>
> >
>
> > > opposite = StrExtract(list, 1);
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > _TRACE(first + " and " + opposite);
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > if (Name() == first) {
>
> >
>
> > >
>
> >
>
> > > SetForeign(opposite );
>
> >
>
> > >
>
> >
>
> > > // Read whatever you want from opposite data
>
> >
>
> > >
>
> >
>
> > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Buy = ... enter long for first symbol
>
> >
>
> > >
>
> >
>
> > > Sell = ... exit long for first symbol;
>
> >
>
> > >
>
> >
>
> > > }
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > if (Name() == opposite) {
>
> >
>
> > >
>
> >
>
> > > SetForeign(first) ;
>
> >
>
> > >
>
> >
>
> > > // Read whatever you want from first data
>
> >
>
> > >
>
> >
>
> > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Buy = ... enter long for opposite symbol
>
> >
>
> > >
>
> >
>
> > > Sell = ... exit long for opposite symbol;
>
> >
>
> > >
>
> >
>
> > > }
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Mike
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
>
> >
>
> > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Thanks so much. I tried it this way and I almost got it. Im
>
> >
>
> > running
>
> >
>
> > >
>
> >
>
> > > it on the first watchlist and then using the setforeign
>
> (opposite );
>
> >
>
> > >
>
> >
>
> > > function. But Im having a problem. There are variables I
declared
>
> >
>
> > >
>
> >
>
> > > early in the code. Then I say setforeign(opposite ); Then put in
>
> buy
>
> >
>
> > >
>
> >
>
> > > conditions based on those variables but I get no buys or sells
in
>
> >
>
> > >
>
> >
>
> > > this foreign ticker. Only buys and sells in the first watchlist.
>
> How
>
> >
>
> > >
>
> >
>
> > > come?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > --- On Sun, 12/14/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > >
>
> >
>
> > > > From: Mike <sfclimbers@ ...>
>
> >
>
> > >
>
> >
>
> > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > > Date: Sunday, December 14, 2008, 2:31 AM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > If you want to go down that route, you might
>
> consider
>
> >
>
> > >
>
> >
>
> > > just two lists,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > each with one side of the pair for each pair, rather than
>
> separate
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > lists per pair.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > e.g.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > instead of:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList1 = A,X
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList2 = M,Y
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList3 = I,Z
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > do:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList1 = A,I,M
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList2 = X,Z,Y
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Then you can run your script on watchList1, making indexed
>
> >
>
> > >
>
> >
>
> > > reference
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > to the symbols in watchList2 as shown below.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Note, however, that I rearanged watchList1 to be in
>
> alphabetical
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > order before adding the indexed opposite symbols in
watchList2.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > It appears that AmiBroker iterates through the active
watchList
>
> in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > alphabetical order (regardless of the order that the symbols
>
> were
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > added to the list). So, you must ensure that the indexed
>
> opposites
>
> >
>
> > >
>
> >
>
> > > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList2 will match their partner based on the assumption
>
> that
>
> >
>
> > >
>
> >
>
> > > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > partners were sorted before being processed by your script.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > If your lists are expected to be relatively unchanging, this
>
> may
>
> >
>
> > be
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > an acceptable bit of book keeping.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Buy = Sell = Short = Cover = 0;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Get opposites from second list, ordered as originally
>
> entered.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > list = CategoryGetSymbols( categoryWatchlis t, 2);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Get alphabetized index of current symbol from first list.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > index = status("stocknum" );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Extract opposite for the current symbol.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > opposite = StrExtract(list, index);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > _TRACE(Name( ) + " and " + opposite);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > SetForeign(opposite );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Do whatever you want with foreign opposite
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Mike
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
>
> <normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > thanks yes Im looking for something like this. In the end I
>
> have
>
> >
>
> > >
>
> >
>
> > > a
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > code that at the beginning designates two symbols.
>
> ticker1=ibm ,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > ticker2=ge for example. Then I run the code.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > The thing is, I have a few of them and I dont want to
>
> manually
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > enter them. Instead I was thinking of putting a couple of
>
> tickers
>
> >
>
> > >
>
> >
>
> > > per
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchlist. Then trying to call upon them by saying take each
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchlist and make first symbol in watchlist = ticker1 and
then
>
> >
>
> > 2nd
>
> >
>
> > >
>
> >
>
> > > =
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > ticker2.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Then run code. Then take watchlist 2 and do the same thing
>
> and
>
> >
>
> > >
>
> >
>
> > > run
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > code.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Is it possible to do that? How would I code that?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > --- On Wed, 12/10/08, Barry Scarborough <razzbarry@ ..>
wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > From: Barry Scarborough <razzbarry@ ..>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Date: Wednesday, December 10, 2008, 11:32 PM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > I an not sure what you are looking for. This
>
> program
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > runs through a
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watch list and processes the the symbols individually. You
>
> can
>
> >
>
> > do
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > all
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > sorts of things within SetForeign() and RestorePriceArrays(
);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Barry
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _SECTION_BEGIN( "Using SetForeign") ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > SetChartOptions( 0, chartShowArrows | chartShowDates );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Filename = StrLeft(_DEFAULT_ NAME(),StrLen( _DEFAULT_
NAME())-
>
> 2)
>
> >
>
> > ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _N(Title = filename + StrFormat(" - {{DATE}} {{VALUES}} "));
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // parameters
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Watchlist = 10;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // create comma separated list of symbols in the watch list
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > list = CategoryGetSymbols( categoryWatchlist, watchlist );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > /*
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > this gets the symbol name and the for loop will process
every
>
> >
>
> > one
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > the watch list for each bar. In an auto trading program it
>
> will
>
> >
>
> > >
>
> >
>
> > > run
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > every time a tick is received
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > */
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > {
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > SetForeign(sym) ; // switches to the symbol array,
>
> OHLCVOi
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > /*
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > put your code here. You can create an include that will
>
> define
>
> >
>
> > >
>
> >
>
> > > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > parameters for each symbol you have optimized and
dynamically
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > switch
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > the parameters for the indicators. You can also dynamically
>
> >
>
> > >
>
> >
>
> > > switch
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > a different system for some symbols. Your imagination is the
>
> >
>
> > >
>
> >
>
> > > limit.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > */
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > }
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _SECTION_END( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
>
> <normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > If you have a code that works on two symbols, is it
>
> possible
>
> >
>
> > >
>
> >
>
> > > call
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > upon the first and second tickers in the watchlist without
>
> >
>
> > having
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > actually manually write the tickers? Like referring to them
>
> as
>
> >
>
> > >
>
> >
>
> > > 1st
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > and 2nd ticker in this specific watchlist. possible?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>

2b.

Re: scrolling through a watchlist

Posted by: "jim fenster" normanjade@xxxxxxcom   normanjade

Thu Dec 18, 2008 8:11 pm (PST)

Ya that works but I have to test one watchlist at a time. Is there no way to say test this on watchlist 1 and 2 at the same time? Not just 1? If I do all symbols it doesn't test properly.

--- On Thu, 12/18/08, Mike <sfclimbers@xxxxxx com> wrote:
From: Mike <sfclimbers@xxxxxx com>
Subject: [amibroker] Re: scrolling through a watchlist
To: amibroker@xxxxxxxxx ps.com
Date: Thursday, December 18, 2008, 9:00 PM

My last post seems to have been lost.

To summarize, make sure that the following line is present and does

not have any embedded spaces between the quotes. Yahoo tends to stuff

in extra blank spaces into these posts.

ab = CreateObject( "Broker.Applicat ion");

Mike

--- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...> wrote:

>

> When I put the beginning of that script in I get messages like:

> COM/object handle is null

> COM object variable is not initialized or has invalid type.

> Its highlighting both the aa = line and the wl= line.

> Am i doing something wrong by just putting it in there?

> is there another way to get the active watchlist number? Cuz that

way I could

> just select all in the AA and through the code get the active

watchlist number and extract the symbols from there. I just dont know

how to get the active watchlist number of the symbol being analyzed.

>

>

> --- On Thu, 12/18/08, Mike <sfclimbers@ ...> wrote:

> From: Mike <sfclimbers@ ...>

> Subject: [amibroker] Re: scrolling through a watchlist

> To: amibroker@xxxxxxxxx ps.com

> Date: Thursday, December 18, 2008, 3:48 PM

>

>

>

>

>

>

>

>

>

>

>

> Just make any number of watchlists that you want, each

with exactly

>

> two symbols. Then, select whichever list you want to work against in

>

> the AA window and run the following script. Select a different

>

> watchlist in the AA window and run the script again. Repeat for as

>

> many lists as you have.

>

>

>

> There may be a cleaner way for getting the active watchlist. But the

>

> method used should work.

>

>

>

> Mike

>

>

>

> --

>

> Buy = Sell = 0;

>

>

>

> ab = CreateObject( "Broker.Applicat ion");

>

> aa = ab.Analysis;

>

> wl = aa.Filter(0, "watchlist") ;

>

>

>

> list = CategoryGetSymbols( categoryWatchlis t, wl);

>

> ticker1 = StrExtract(list, 0);

>

> ticker2 = StrExtract(list, 1);

>

>

>

> _TRACE(CategoryGetN ame(categoryWatc hlist, wl) + ": " + ticker1 + "

>

> and " + ticker2);

>

>

>

> if (Name() == ticker1) {

>

> SetForeign(ticker2) ;

>

> // Read whatever you want from second data, e.g.

>

> foreignClose = Close;

>

> RestorePriceArrays( );

>

>

>

> Buy = foreignClose > Close;

>

> Sell = foreignClose < Close;

>

> }

>

>

>

> if (Name() == ticker2) {

>

> SetForeign(ticker1) ;

>

> // Read whatever you want from first data, e.g.

>

> foreignHigh = High;

>

> RestorePriceArrays( );

>

>

>

> Buy = foreignHigh > High;

>

> Sell = foreignHigh < High;

>

> }

>

>

>

> --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>

wrote:

>

> >

>

> > Your totally right actually. As long as the list is finite that

>

> should be fine. Im such a newbie at this coding though so the

>

> simplest things are difficult.

>

> > How do I say:

>

> > If current ticker belongs to watchlist1, then ticker1=F and

>

> ticker2=GM.

>

> >

>

> > Ticker1 and Ticker2 are parts of my code. Then I figure I do it

>

> this way. Next writing if current ticker belongs to watchlist2

>

> then ....

>

> > Then I run the code. I think that way would be the best.

>

> >

>

> > --- On Wed, 12/17/08, Mike <sfclimbers@ ...> wrote:

>

> > From: Mike <sfclimbers@ ...>

>

> > Subject: [amibroker] Re: scrolling through a watchlist

>

> > To: amibroker@xxxxxxxxx ps.com

>

> > Date: Wednesday, December 17, 2008, 11:57 PM

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> > What's wrong with the "both symbols in a single list"

>

> approach? I

>

> >

>

> > believe that the assumption is that you would have multiple lists,

>

> >

>

> > each with exactly two symbols (as you had originally suggested).

>

> Where

>

> >

>

> > are you running into problems?

>

> >

>

> >

>

> >

>

> > If it's a case of the script logic not being applicable from one

>

> pair

>

> >

>

> > to the next, then the whole hard coding of names problem goes away

>

> >

>

> > because each script would be customized to a pair and you could

>

> hard

>

> >

>

> > code the names after all, as per Tomasz's example. Otherwise, were

>

> you

>

> >

>

> > not able to dig out the names correctly using StrExtract?

>

> >

>

> >

>

> >

>

> > Mike

>

> >

>

> >

>

> >

>

> > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>

>

> wrote:

>

> >

>

> > >

>

> >

>

> > > Ya that code isn't working very well. Also all the 1st part of

>

> the

>

> >

>

> > pairs in one watchlists and the seconds in a second list can't

>

> really

>

> >

>

> > work because its alphabetizing each list. So when I enter the

>

> orders

>

> >

>

> > for the first list its fine, but then I get to the second list and

>

> it

>

> >

>

> > alphabetizes that so it ruins the order with the first list. This

>

> is

>

> >

>

> > tough man!

>

> >

>

> > >

>

> >

>

> > > --- On Mon, 12/15/08, Mike <sfclimbers@ ...> wrote:

>

> >

>

> > > From: Mike <sfclimbers@ ...>

>

> >

>

> > > Subject: [amibroker] Re: scrolling through a watchlist

>

> >

>

> > > To: amibroker@xxxxxxxxx ps.com

>

> >

>

> > > Date: Monday, December 15, 2008, 8:21 PM

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Hi,

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Sorry, it was not clear that you were wanting to act on both

>

> >

>

> > symbols.

>

> >

>

> > >

>

> >

>

> > > I thought you were trying to buy from the first list only, based

>

> on

>

> >

>

> > >

>

> >

>

> > > signals/confirmatio n from the second list.

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > As you've now discovered, the Foreign functionality allows

access

>

> to

>

> >

>

> > >

>

> >

>

> > > foreign data, but it does not allow you to generate signals for

>

> that

>

> >

>

> > >

>

> >

>

> > > foreign symbol. To act on the symbol, it must appear in the

>

> >

>

> > watchlist

>

> >

>

> > >

>

> >

>

> > > and be processed in turn.

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Tomasz has answered your question, which is the route that you

>

> were

>

> >

>

> > >

>

> >

>

> > > originally heading down. But, he did not address the hard coded

>

> >

>

> > names

>

> >

>

> > >

>

> >

>

> > > that you were trying to avoid.

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > To avoid the hard coded names of Tomasz's answer, Dingo gave you

>

> the

>

> >

>

> > >

>

> >

>

> > > answer, which is also what I used in my earlier sample.

>

> >

>

> > Specifically;

>

> >

>

> > >

>

> >

>

> > > use StrExtract from the watchlist.

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Putting it all togeather...

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Again the symbols will be evaluated in alphabetical order, but

>

> >

>

> > >

>

> >

>

> > > CategoryGetSymbols will give the ordering as they appear in the

>

> >

>

> > >

>

> >

>

> > > watchlist (i.e. not necessarily alphabetized) . So, if it

>

> matters,

>

> >

>

> > >

>

> >

>

> > > populate your list such that the symbol you want to to be

treated

>

> as

>

> >

>

> > >

>

> >

>

> > > first actually appears first in the watchlist, even though the

>

> >

>

> > second

>

> >

>

> > >

>

> >

>

> > > may get run through the script before the first one.

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Buy = Sell = Short = Cover = 0;

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > list = CategoryGetSymbols( categoryWatchlis t, 1);

>

> >

>

> > >

>

> >

>

> > > first = StrExtract(list, 0);

>

> >

>

> > >

>

> >

>

> > > opposite = StrExtract(list, 1);

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > _TRACE(first + " and " + opposite);

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > if (Name() == first) {

>

> >

>

> > >

>

> >

>

> > > SetForeign(opposite );

>

> >

>

> > >

>

> >

>

> > > // Read whatever you want from opposite data

>

> >

>

> > >

>

> >

>

> > > RestorePriceArrays( );

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Buy = ... enter long for first symbol

>

> >

>

> > >

>

> >

>

> > > Sell = ... exit long for first symbol;

>

> >

>

> > >

>

> >

>

> > > }

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > if (Name() == opposite) {

>

> >

>

> > >

>

> >

>

> > > SetForeign(first) ;

>

> >

>

> > >

>

> >

>

> > > // Read whatever you want from first data

>

> >

>

> > >

>

> >

>

> > > RestorePriceArrays( );

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Buy = ... enter long for opposite symbol

>

> >

>

> > >

>

> >

>

> > > Sell = ... exit long for opposite symbol;

>

> >

>

> > >

>

> >

>

> > > }

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > Mike

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > >

>

> >

>

> > > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>

>

> >

>

> > wrote:

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > Thanks so much. I tried it this way and I almost got it. Im

>

> >

>

> > running

>

> >

>

> > >

>

> >

>

> > > it on the first watchlist and then using the setforeign

>

> (opposite );

>

> >

>

> > >

>

> >

>

> > > function. But Im having a problem. There are variables I

declared

>

> >

>

> > >

>

> >

>

> > > early in the code. Then I say setforeign(opposite ); Then put in

>

> buy

>

> >

>

> > >

>

> >

>

> > > conditions based on those variables but I get no buys or sells

in

>

> >

>

> > >

>

> >

>

> > > this foreign ticker. Only buys and sells in the first watchlist.

>

> How

>

> >

>

> > >

>

> >

>

> > > come?

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > --- On Sun, 12/14/08, Mike <sfclimbers@ ...> wrote:

>

> >

>

> > >

>

> >

>

> > > > From: Mike <sfclimbers@ ...>

>

> >

>

> > >

>

> >

>

> > > > Subject: [amibroker] Re: scrolling through a watchlist

>

> >

>

> > >

>

> >

>

> > > > To: amibroker@xxxxxxxxx ps.com

>

> >

>

> > >

>

> >

>

> > > > Date: Sunday, December 14, 2008, 2:31 AM

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > If you want to go down that route, you might

>

> consider

>

> >

>

> > >

>

> >

>

> > > just two lists,

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > each with one side of the pair for each pair, rather than

>

> separate

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > lists per pair.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > e.g.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > instead of:

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchList1 = A,X

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchList2 = M,Y

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchList3 = I,Z

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > do:

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchList1 = A,I,M

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchList2 = X,Z,Y

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > Then you can run your script on watchList1, making indexed

>

> >

>

> > >

>

> >

>

> > > reference

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > to the symbols in watchList2 as shown below.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > Note, however, that I rearanged watchList1 to be in

>

> alphabetical

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > order before adding the indexed opposite symbols in

watchList2.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > It appears that AmiBroker iterates through the active

watchList

>

> in

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > alphabetical order (regardless of the order that the symbols

>

> were

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > added to the list). So, you must ensure that the indexed

>

> opposites

>

> >

>

> > >

>

> >

>

> > > in

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchList2 will match their partner based on the assumption

>

> that

>

> >

>

> > >

>

> >

>

> > > the

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > partners were sorted before being processed by your script.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > If your lists are expected to be relatively unchanging, this

>

> may

>

> >

>

> > be

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > an acceptable bit of book keeping.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > Buy = Sell = Short = Cover = 0;

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > // Get opposites from second list, ordered as originally

>

> entered.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > list = CategoryGetSymbols( categoryWatchlis t, 2);

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > // Get alphabetized index of current symbol from first list.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > index = status("stocknum" );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > // Extract opposite for the current symbol.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > opposite = StrExtract(list, index);

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > _TRACE(Name( ) + " and " + opposite);

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > SetForeign(opposite );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > // Do whatever you want with foreign opposite

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > RestorePriceArrays( );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > Mike

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster

>

> <normanjade@ ...>

>

> >

>

> > >

>

> >

>

> > > wrote:

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > thanks yes Im looking for something like this. In the end I

>

> have

>

> >

>

> > >

>

> >

>

> > > a

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > code that at the beginning designates two symbols.

>

> ticker1=ibm ,

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > ticker2=ge for example. Then I run the code.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > The thing is, I have a few of them and I dont want to

>

> manually

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > enter them. Instead I was thinking of putting a couple of

>

> tickers

>

> >

>

> > >

>

> >

>

> > > per

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchlist. Then trying to call upon them by saying take each

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > watchlist and make first symbol in watchlist = ticker1 and

then

>

> >

>

> > 2nd

>

> >

>

> > >

>

> >

>

> > > =

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > ticker2.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Then run code. Then take watchlist 2 and do the same thing

>

> and

>

> >

>

> > >

>

> >

>

> > > run

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > code.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Is it possible to do that? How would I code that?

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > --- On Wed, 12/10/08, Barry Scarborough <razzbarry@ ..>

wrote:

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > From: Barry Scarborough <razzbarry@ ..>

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Subject: [amibroker] Re: scrolling through a watchlist

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > To: amibroker@xxxxxxxxx ps.com

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Date: Wednesday, December 10, 2008, 11:32 PM

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > I an not sure what you are looking for. This

>

> program

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > runs through a

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > watch list and processes the the symbols individually. You

>

> can

>

> >

>

> > do

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > all

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > sorts of things within SetForeign() and RestorePriceArrays(

);

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Barry

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > _SECTION_BEGIN( "Using SetForeign") ;

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > SetChartOptions( 0, chartShowArrows | chartShowDates );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Filename = StrLeft(_DEFAULT_ NAME(),StrLen( _DEFAULT_

NAME())-

>

> 2)

>

> >

>

> > ;

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > _N(Title = filename + StrFormat(" - {{DATE}} {{VALUES}} "));

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > // parameters

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > Watchlist = 10;

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > // create comma separated list of symbols in the watch list

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > list = CategoryGetSymbols( categoryWatchlist, watchlist );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > /*

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > this gets the symbol name and the for loop will process

every

>

> >

>

> > one

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > in

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > the watch list for each bar. In an auto trading program it

>

> will

>

> >

>

> > >

>

> >

>

> > > run

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > every time a tick is received

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > */

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > {

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > SetForeign(sym) ; // switches to the symbol array,

>

> OHLCVOi

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > /*

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > put your code here. You can create an include that will

>

> define

>

> >

>

> > >

>

> >

>

> > > the

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > parameters for each symbol you have optimized and

dynamically

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > switch

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > the parameters for the indicators. You can also dynamically

>

> >

>

> > >

>

> >

>

> > > switch

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > to

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > a different system for some symbols. Your imagination is the

>

> >

>

> > >

>

> >

>

> > > limit.

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > */

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > RestorePriceArrays( );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > }

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > _SECTION_END( );

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster

>

> <normanjade@ ...>

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > wrote:

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > > If you have a code that works on two symbols, is it

>

> possible

>

> >

>

> > >

>

> >

>

> > > call

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > upon the first and second tickers in the watchlist without

>

> >

>

> > having

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > to

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > actually manually write the tickers? Like referring to them

>

> as

>

> >

>

> > >

>

> >

>

> > > 1st

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > and 2nd ticker in this specific watchlist. possible?

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>

> > > > >

>

> >

>

> > >

>

> >

>

> > > >

>

> >

>

> > >

>

> >

>











2c.

Re: scrolling through a watchlist

Posted by: "Mike" sfclimbers@xxxxxxcom   sfclimbers

Fri Dec 19, 2008 12:51 am (PST)

You can have a look at BatMan in the files section for running your
script as a batch over different watchlists each time.

Or, if you just want a single watchlist of multiple pairs upon which
you make a single AmiBroker execution, then just add a loop to the
code

Make sure that the pairs are all added to a single list in paired
order. e.g.

ticker1
ticker2
ticker1
ticker2
...

This will not be practical if you have many many pairs. But, for a
reasonably small set of pairs, it will do the job.

Mike

Buy = Sell = 0;

ab = CreateObject( "Broker.Applicat ion");
aa = ab.Analysis;
wl = aa.Filter(0, "watchlist") ;

list = CategoryGetSymbols( categoryWatchlis t, wl);

for (i = 0; (ticker1 = StrExtract(list, i)) != ""; i++) {
if ((ticker2 = StrExtract(list, ++i)) == "") {
break;
}

_TRACE(CategoryGetN ame(categoryWatc hlist, wl) + ": " + ticker1 + "
and " + ticker2);

if (Name() == ticker1) {
SetForeign(ticker2) ;
// Read whatever you want from second data, e.g.
foreignClose = Close;
RestorePriceArrays( );

Buy = foreignClose > Close;
Sell = foreignClose < Close;
}

if (Name() == ticker2) {
SetForeign(ticker1) ;
// Read whatever you want from first data, e.g.
foreignHigh = High;
RestorePriceArrays( );

Buy = foreignHigh > High;
Sell = foreignHigh < High;
}
}

--- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...> wrote:
>
> Ya that works but I have to test one watchlist at a time. Is there
no way to say test this on watchlist 1 and 2 at the same time? Not
just 1? If I do all symbols it doesn't test properly.
>
> --- On Thu, 12/18/08, Mike <sfclimbers@ ...> wrote:
> From: Mike <sfclimbers@ ...>
> Subject: [amibroker] Re: scrolling through a watchlist
> To: amibroker@xxxxxxxxx ps.com
> Date: Thursday, December 18, 2008, 9:00 PM
>
>
>
>
>
>
>
>
>
>
>
> My last post seems to have been lost.
>
> To summarize, make sure that the following line is present and does
>
> not have any embedded spaces between the quotes. Yahoo tends to
stuff
>
> in extra blank spaces into these posts.
>
>
>
> ab = CreateObject( "Broker.Applicat ion");
>
>
>
> Mike
>
>
>
> --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
wrote:
>
> >
>
> > When I put the beginning of that script in I get messages like:
>
> > COM/object handle is null
>
> > COM object variable is not initialized or has invalid type.
>
> > Its highlighting both the aa = line and the wl= line.
>
> > Am i doing something wrong by just putting it in there?
>
> > is there another way to get the active watchlist number? Cuz that
>
> way I could
>
> > just select all in the AA and through the code get the active
>
> watchlist number and extract the symbols from there. I just dont
know
>
> how to get the active watchlist number of the symbol being analyzed.
>
> >
>
> >
>
> > --- On Thu, 12/18/08, Mike <sfclimbers@ ...> wrote:
>
> > From: Mike <sfclimbers@ ...>
>
> > Subject: [amibroker] Re: scrolling through a watchlist
>
> > To: amibroker@xxxxxxxxx ps.com
>
> > Date: Thursday, December 18, 2008, 3:48 PM
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > Just make any number of watchlists that you want,
each
>
> with exactly
>
> >
>
> > two symbols. Then, select whichever list you want to work against
in
>
> >
>
> > the AA window and run the following script. Select a different
>
> >
>
> > watchlist in the AA window and run the script again. Repeat for
as
>
> >
>
> > many lists as you have.
>
> >
>
> >
>
> >
>
> > There may be a cleaner way for getting the active watchlist. But
the
>
> >
>
> > method used should work.
>
> >
>
> >
>
> >
>
> > Mike
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > Buy = Sell = 0;
>
> >
>
> >
>
> >
>
> > ab = CreateObject( "Broker.Applicat ion");
>
> >
>
> > aa = ab.Analysis;
>
> >
>
> > wl = aa.Filter(0, "watchlist") ;
>
> >
>
> >
>
> >
>
> > list = CategoryGetSymbols( categoryWatchlis t, wl);
>
> >
>
> > ticker1 = StrExtract(list, 0);
>
> >
>
> > ticker2 = StrExtract(list, 1);
>
> >
>
> >
>
> >
>
> > _TRACE(CategoryGetN ame(categoryWatc hlist, wl) + ": " + ticker1
+ "
>
> >
>
> > and " + ticker2);
>
> >
>
> >
>
> >
>
> > if (Name() == ticker1) {
>
> >
>
> > SetForeign(ticker2) ;
>
> >
>
> > // Read whatever you want from second data, e.g.
>
> >
>
> > foreignClose = Close;
>
> >
>
> > RestorePriceArrays( );
>
> >
>
> >
>
> >
>
> > Buy = foreignClose > Close;
>
> >
>
> > Sell = foreignClose < Close;
>
> >
>
> > }
>
> >
>
> >
>
> >
>
> > if (Name() == ticker2) {
>
> >
>
> > SetForeign(ticker1) ;
>
> >
>
> > // Read whatever you want from first data, e.g.
>
> >
>
> > foreignHigh = High;
>
> >
>
> > RestorePriceArrays( );
>
> >
>
> >
>
> >
>
> > Buy = foreignHigh > High;
>
> >
>
> > Sell = foreignHigh < High;
>
> >
>
> > }
>
> >
>
> >
>
> >
>
> > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
>
> wrote:
>
> >
>
> > >
>
> >
>
> > > Your totally right actually. As long as the list is finite that
>
> >
>
> > should be fine. Im such a newbie at this coding though so the
>
> >
>
> > simplest things are difficult.
>
> >
>
> > > How do I say:
>
> >
>
> > > If current ticker belongs to watchlist1, then ticker1=F and
>
> >
>
> > ticker2=GM.
>
> >
>
> > >
>
> >
>
> > > Ticker1 and Ticker2 are parts of my code. Then I figure I do it
>
> >
>
> > this way. Next writing if current ticker belongs to watchlist2
>
> >
>
> > then ....
>
> >
>
> > > Then I run the code. I think that way would be the best.
>
> >
>
> > >
>
> >
>
> > > --- On Wed, 12/17/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > > From: Mike <sfclimbers@ ...>
>
> >
>
> > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > > Date: Wednesday, December 17, 2008, 11:57 PM
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > What's wrong with the "both symbols in a single
list"
>
> >
>
> > approach? I
>
> >
>
> > >
>
> >
>
> > > believe that the assumption is that you would have multiple
lists,
>
> >
>
> > >
>
> >
>
> > > each with exactly two symbols (as you had originally
suggested).
>
> >
>
> > Where
>
> >
>
> > >
>
> >
>
> > > are you running into problems?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If it's a case of the script logic not being applicable from
one
>
> >
>
> > pair
>
> >
>
> > >
>
> >
>
> > > to the next, then the whole hard coding of names problem goes
away
>
> >
>
> > >
>
> >
>
> > > because each script would be customized to a pair and you could
>
> >
>
> > hard
>
> >
>
> > >
>
> >
>
> > > code the names after all, as per Tomasz's example. Otherwise,
were
>
> >
>
> > you
>
> >
>
> > >
>
> >
>
> > > not able to dig out the names correctly using StrExtract?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Mike
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
<normanjade@ ...>
>
> >
>
> > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Ya that code isn't working very well. Also all the 1st part
of
>
> >
>
> > the
>
> >
>
> > >
>
> >
>
> > > pairs in one watchlists and the seconds in a second list can't
>
> >
>
> > really
>
> >
>
> > >
>
> >
>
> > > work because its alphabetizing each list. So when I enter the
>
> >
>
> > orders
>
> >
>
> > >
>
> >
>
> > > for the first list its fine, but then I get to the second list
and
>
> >
>
> > it
>
> >
>
> > >
>
> >
>
> > > alphabetizes that so it ruins the order with the first list.
This
>
> >
>
> > is
>
> >
>
> > >
>
> >
>
> > > tough man!
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > --- On Mon, 12/15/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > >
>
> >
>
> > > > From: Mike <sfclimbers@ ...>
>
> >
>
> > >
>
> >
>
> > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > > Date: Monday, December 15, 2008, 8:21 PM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Hi,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Sorry, it was not clear that you were wanting to act on both
>
> >
>
> > >
>
> >
>
> > > symbols.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > I thought you were trying to buy from the first list only,
based
>
> >
>
> > on
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > signals/confirmatio n from the second list.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > As you've now discovered, the Foreign functionality allows
>
> access
>
> >
>
> > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > foreign data, but it does not allow you to generate signals
for
>
> >
>
> > that
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > foreign symbol. To act on the symbol, it must appear in the
>
> >
>
> > >
>
> >
>
> > > watchlist
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > and be processed in turn.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Tomasz has answered your question, which is the route that
you
>
> >
>
> > were
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > originally heading down. But, he did not address the hard
coded
>
> >
>
> > >
>
> >
>
> > > names
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > that you were trying to avoid.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > To avoid the hard coded names of Tomasz's answer, Dingo gave
you
>
> >
>
> > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > answer, which is also what I used in my earlier sample.
>
> >
>
> > >
>
> >
>
> > > Specifically;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > use StrExtract from the watchlist.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Putting it all togeather...
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Again the symbols will be evaluated in alphabetical order,
but
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > CategoryGetSymbols will give the ordering as they appear in
the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchlist (i.e. not necessarily alphabetized) . So, if it
>
> >
>
> > matters,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > populate your list such that the symbol you want to to be
>
> treated
>
> >
>
> > as
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > first actually appears first in the watchlist, even though
the
>
> >
>
> > >
>
> >
>
> > > second
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > may get run through the script before the first one.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Buy = Sell = Short = Cover = 0;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > list = CategoryGetSymbols( categoryWatchlis t, 1);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > first = StrExtract(list, 0);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > opposite = StrExtract(list, 1);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > _TRACE(first + " and " + opposite);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > if (Name() == first) {
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > SetForeign(opposite );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Read whatever you want from opposite data
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Buy = ... enter long for first symbol
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Sell = ... exit long for first symbol;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > }
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > if (Name() == opposite) {
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > SetForeign(first) ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Read whatever you want from first data
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Buy = ... enter long for opposite symbol
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Sell = ... exit long for opposite symbol;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > }
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Mike
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
<normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Thanks so much. I tried it this way and I almost got it. Im
>
> >
>
> > >
>
> >
>
> > > running
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > it on the first watchlist and then using the setforeign
>
> >
>
> > (opposite );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > function. But Im having a problem. There are variables I
>
> declared
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > early in the code. Then I say setforeign(opposite ); Then put
in
>
> >
>
> > buy
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > conditions based on those variables but I get no buys or
sells
>
> in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > this foreign ticker. Only buys and sells in the first
watchlist.
>
> >
>
> > How
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > come?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > --- On Sun, 12/14/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > From: Mike <sfclimbers@ ...>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Date: Sunday, December 14, 2008, 2:31 AM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > If you want to go down that route, you might
>
> >
>
> > consider
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > just two lists,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > each with one side of the pair for each pair, rather than
>
> >
>
> > separate
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > lists per pair.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > e.g.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > instead of:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchList1 = A,X
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchList2 = M,Y
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchList3 = I,Z
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > do:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchList1 = A,I,M
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchList2 = X,Z,Y
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Then you can run your script on watchList1, making indexed
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > reference
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > to the symbols in watchList2 as shown below.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Note, however, that I rearanged watchList1 to be in
>
> >
>
> > alphabetical
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > order before adding the indexed opposite symbols in
>
> watchList2.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > It appears that AmiBroker iterates through the active
>
> watchList
>
> >
>
> > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > alphabetical order (regardless of the order that the
symbols
>
> >
>
> > were
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > added to the list). So, you must ensure that the indexed
>
> >
>
> > opposites
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchList2 will match their partner based on the assumption
>
> >
>
> > that
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > partners were sorted before being processed by your script.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > If your lists are expected to be relatively unchanging,
this
>
> >
>
> > may
>
> >
>
> > >
>
> >
>
> > > be
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > an acceptable bit of book keeping.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Buy = Sell = Short = Cover = 0;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // Get opposites from second list, ordered as originally
>
> >
>
> > entered.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > list = CategoryGetSymbols( categoryWatchlis t, 2);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // Get alphabetized index of current symbol from first list.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > index = status("stocknum" );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // Extract opposite for the current symbol.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > opposite = StrExtract(list, index);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _TRACE(Name( ) + " and " + opposite);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > SetForeign(opposite );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // Do whatever you want with foreign opposite
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Mike
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
>
> >
>
> > <normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > thanks yes Im looking for something like this. In the end
I
>
> >
>
> > have
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > a
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > code that at the beginning designates two symbols.
>
> >
>
> > ticker1=ibm ,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > ticker2=ge for example. Then I run the code.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > The thing is, I have a few of them and I dont want to
>
> >
>
> > manually
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > enter them. Instead I was thinking of putting a couple of
>
> >
>
> > tickers
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > per
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchlist. Then trying to call upon them by saying take
each
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watchlist and make first symbol in watchlist = ticker1 and
>
> then
>
> >
>
> > >
>
> >
>
> > > 2nd
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > =
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > ticker2.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Then run code. Then take watchlist 2 and do the same
thing
>
> >
>
> > and
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > run
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > code.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Is it possible to do that? How would I code that?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > --- On Wed, 12/10/08, Barry Scarborough <razzbarry@ ..>
>
> wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > From: Barry Scarborough <razzbarry@ ..>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Date: Wednesday, December 10, 2008, 11:32 PM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > I an not sure what you are looking for. This
>
> >
>
> > program
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > runs through a
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > watch list and processes the the symbols individually.
You
>
> >
>
> > can
>
> >
>
> > >
>
> >
>
> > > do
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > all
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > sorts of things within SetForeign() and RestorePriceArrays
(
>
> );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Barry
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > _SECTION_BEGIN( "Using SetForeign") ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > SetChartOptions( 0, chartShowArrows | chartShowDates );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Filename = StrLeft(_DEFAULT_ NAME(),StrLen( _DEFAULT_
>
> NAME())-
>
> >
>
> > 2)
>
> >
>
> > >
>
> >
>
> > > ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > _N(Title = filename + StrFormat(" - {{DATE}}
{{VALUES}} "));
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > // parameters
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > Watchlist = 10;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > // create comma separated list of symbols in the watch
list
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > list = CategoryGetSymbols( categoryWatchlist,
watchlist );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > /*
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > this gets the symbol name and the for loop will process
>
> every
>
> >
>
> > >
>
> >
>
> > > one
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > the watch list for each bar. In an auto trading program
it
>
> >
>
> > will
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > run
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > every time a tick is received
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > */
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > {
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > SetForeign(sym) ; // switches to the symbol array,
>
> >
>
> > OHLCVOi
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > /*
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > put your code here. You can create an include that will
>
> >
>
> > define
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > parameters for each symbol you have optimized and
>
> dynamically
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > switch
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > the parameters for the indicators. You can also
dynamically
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > switch
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > a different system for some symbols. Your imagination is
the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > limit.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > */
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > }
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > _SECTION_END( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
>
> >
>
> > <normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > > If you have a code that works on two symbols, is it
>
> >
>
> > possible
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > call
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > upon the first and second tickers in the watchlist
without
>
> >
>
> > >
>
> >
>
> > > having
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > actually manually write the tickers? Like referring to
them
>
> >
>
> > as
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > 1st
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > and 2nd ticker in this specific watchlist. possible?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>

2d.

Re: scrolling through a watchlist

Posted by: "Mike" sfclimbers@xxxxxxcom   sfclimbers

Fri Dec 19, 2008 2:45 am (PST)

It's working fine for me. Have you copied the whole script, including
the line:

ab = CreateObject( "Broker.Application ");

Make sure that no extra spaces or any other corruption got added to
the quoted string "Broker.Application " which should not have any
spaces in it. Sometimes Yahoo stuffs in spaces to your posts.

Mike

--- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...> wrote:
>
> When I put the beginning of that script in I get messages like:
> COM/object handle is null
> COM object variable is not initialized or has invalid type.
> Its highlighting both the aa = line and the wl= line.
> Am i doing something wrong by just putting it in there?
> is there another way to get the active watchlist number? Cuz that
way I could
> just select all in the AA and through the code get the active
watchlist number and extract the symbols from there. I just dont know
how to get the active watchlist number of the symbol being analyzed.
>
>
> --- On Thu, 12/18/08, Mike <sfclimbers@ ...> wrote:
> From: Mike <sfclimbers@ ...>
> Subject: [amibroker] Re: scrolling through a watchlist
> To: amibroker@xxxxxxxxx ps.com
> Date: Thursday, December 18, 2008, 3:48 PM
>
>
>
>
>
>
>
>
>
>
>
> Just make any number of watchlists that you want, each
with exactly
>
> two symbols. Then, select whichever list you want to work against in
>
> the AA window and run the following script. Select a different
>
> watchlist in the AA window and run the script again. Repeat for as
>
> many lists as you have.
>
>
>
> There may be a cleaner way for getting the active watchlist. But the
>
> method used should work.
>
>
>
> Mike
>
>
>
> --
>
> Buy = Sell = 0;
>
>
>
> ab = CreateObject( "Broker.Applicat ion");
>
> aa = ab.Analysis;
>
> wl = aa.Filter(0, "watchlist") ;
>
>
>
> list = CategoryGetSymbols( categoryWatchlis t, wl);
>
> ticker1 = StrExtract(list, 0);
>
> ticker2 = StrExtract(list, 1);
>
>
>
> _TRACE(CategoryGetN ame(categoryWatc hlist, wl) + ": " + ticker1 + "
>
> and " + ticker2);
>
>
>
> if (Name() == ticker1) {
>
> SetForeign(ticker2) ;
>
> // Read whatever you want from second data, e.g.
>
> foreignClose = Close;
>
> RestorePriceArrays( );
>
>
>
> Buy = foreignClose > Close;
>
> Sell = foreignClose < Close;
>
> }
>
>
>
> if (Name() == ticker2) {
>
> SetForeign(ticker1) ;
>
> // Read whatever you want from first data, e.g.
>
> foreignHigh = High;
>
> RestorePriceArrays( );
>
>
>
> Buy = foreignHigh > High;
>
> Sell = foreignHigh < High;
>
> }
>
>
>
> --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
wrote:
>
> >
>
> > Your totally right actually. As long as the list is finite that
>
> should be fine. Im such a newbie at this coding though so the
>
> simplest things are difficult.
>
> > How do I say:
>
> > If current ticker belongs to watchlist1, then ticker1=F and
>
> ticker2=GM.
>
> >
>
> > Ticker1 and Ticker2 are parts of my code. Then I figure I do it
>
> this way. Next writing if current ticker belongs to watchlist2
>
> then ....
>
> > Then I run the code. I think that way would be the best.
>
> >
>
> > --- On Wed, 12/17/08, Mike <sfclimbers@ ...> wrote:
>
> > From: Mike <sfclimbers@ ...>
>
> > Subject: [amibroker] Re: scrolling through a watchlist
>
> > To: amibroker@xxxxxxxxx ps.com
>
> > Date: Wednesday, December 17, 2008, 11:57 PM
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > What's wrong with the "both symbols in a single list"
>
> approach? I
>
> >
>
> > believe that the assumption is that you would have multiple lists,
>
> >
>
> > each with exactly two symbols (as you had originally suggested).
>
> Where
>
> >
>
> > are you running into problems?
>
> >
>
> >
>
> >
>
> > If it's a case of the script logic not being applicable from one
>
> pair
>
> >
>
> > to the next, then the whole hard coding of names problem goes away
>
> >
>
> > because each script would be customized to a pair and you could
>
> hard
>
> >
>
> > code the names after all, as per Tomasz's example. Otherwise, were
>
> you
>
> >
>
> > not able to dig out the names correctly using StrExtract?
>
> >
>
> >
>
> >
>
> > Mike
>
> >
>
> >
>
> >
>
> > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
>
> wrote:
>
> >
>
> > >
>
> >
>
> > > Ya that code isn't working very well. Also all the 1st part of
>
> the
>
> >
>
> > pairs in one watchlists and the seconds in a second list can't
>
> really
>
> >
>
> > work because its alphabetizing each list. So when I enter the
>
> orders
>
> >
>
> > for the first list its fine, but then I get to the second list and
>
> it
>
> >
>
> > alphabetizes that so it ruins the order with the first list. This
>
> is
>
> >
>
> > tough man!
>
> >
>
> > >
>
> >
>
> > > --- On Mon, 12/15/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > > From: Mike <sfclimbers@ ...>
>
> >
>
> > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > > Date: Monday, December 15, 2008, 8:21 PM
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Hi,
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Sorry, it was not clear that you were wanting to act on both
>
> >
>
> > symbols.
>
> >
>
> > >
>
> >
>
> > > I thought you were trying to buy from the first list only, based
>
> on
>
> >
>
> > >
>
> >
>
> > > signals/confirmatio n from the second list.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > As you've now discovered, the Foreign functionality allows
access
>
> to
>
> >
>
> > >
>
> >
>
> > > foreign data, but it does not allow you to generate signals for
>
> that
>
> >
>
> > >
>
> >
>
> > > foreign symbol. To act on the symbol, it must appear in the
>
> >
>
> > watchlist
>
> >
>
> > >
>
> >
>
> > > and be processed in turn.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Tomasz has answered your question, which is the route that you
>
> were
>
> >
>
> > >
>
> >
>
> > > originally heading down. But, he did not address the hard coded
>
> >
>
> > names
>
> >
>
> > >
>
> >
>
> > > that you were trying to avoid.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > To avoid the hard coded names of Tomasz's answer, Dingo gave you
>
> the
>
> >
>
> > >
>
> >
>
> > > answer, which is also what I used in my earlier sample.
>
> >
>
> > Specifically;
>
> >
>
> > >
>
> >
>
> > > use StrExtract from the watchlist.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Putting it all togeather...
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Again the symbols will be evaluated in alphabetical order, but
>
> >
>
> > >
>
> >
>
> > > CategoryGetSymbols will give the ordering as they appear in the
>
> >
>
> > >
>
> >
>
> > > watchlist (i.e. not necessarily alphabetized) . So, if it
>
> matters,
>
> >
>
> > >
>
> >
>
> > > populate your list such that the symbol you want to to be
treated
>
> as
>
> >
>
> > >
>
> >
>
> > > first actually appears first in the watchlist, even though the
>
> >
>
> > second
>
> >
>
> > >
>
> >
>
> > > may get run through the script before the first one.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Buy = Sell = Short = Cover = 0;
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > list = CategoryGetSymbols( categoryWatchlis t, 1);
>
> >
>
> > >
>
> >
>
> > > first = StrExtract(list, 0);
>
> >
>
> > >
>
> >
>
> > > opposite = StrExtract(list, 1);
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > _TRACE(first + " and " + opposite);
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > if (Name() == first) {
>
> >
>
> > >
>
> >
>
> > > SetForeign(opposite );
>
> >
>
> > >
>
> >
>
> > > // Read whatever you want from opposite data
>
> >
>
> > >
>
> >
>
> > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Buy = ... enter long for first symbol
>
> >
>
> > >
>
> >
>
> > > Sell = ... exit long for first symbol;
>
> >
>
> > >
>
> >
>
> > > }
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > if (Name() == opposite) {
>
> >
>
> > >
>
> >
>
> > > SetForeign(first) ;
>
> >
>
> > >
>
> >
>
> > > // Read whatever you want from first data
>
> >
>
> > >
>
> >
>
> > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Buy = ... enter long for opposite symbol
>
> >
>
> > >
>
> >
>
> > > Sell = ... exit long for opposite symbol;
>
> >
>
> > >
>
> >
>
> > > }
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Mike
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > --- In amibroker@xxxxxxxxx ps.com, jim fenster <normanjade@ ...>
>
> >
>
> > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Thanks so much. I tried it this way and I almost got it. Im
>
> >
>
> > running
>
> >
>
> > >
>
> >
>
> > > it on the first watchlist and then using the setforeign
>
> (opposite );
>
> >
>
> > >
>
> >
>
> > > function. But Im having a problem. There are variables I
declared
>
> >
>
> > >
>
> >
>
> > > early in the code. Then I say setforeign(opposite ); Then put in
>
> buy
>
> >
>
> > >
>
> >
>
> > > conditions based on those variables but I get no buys or sells
in
>
> >
>
> > >
>
> >
>
> > > this foreign ticker. Only buys and sells in the first watchlist.
>
> How
>
> >
>
> > >
>
> >
>
> > > come?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > --- On Sun, 12/14/08, Mike <sfclimbers@ ...> wrote:
>
> >
>
> > >
>
> >
>
> > > > From: Mike <sfclimbers@ ...>
>
> >
>
> > >
>
> >
>
> > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > > Date: Sunday, December 14, 2008, 2:31 AM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > If you want to go down that route, you might
>
> consider
>
> >
>
> > >
>
> >
>
> > > just two lists,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > each with one side of the pair for each pair, rather than
>
> separate
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > lists per pair.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > e.g.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > instead of:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList1 = A,X
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList2 = M,Y
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList3 = I,Z
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > do:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList1 = A,I,M
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList2 = X,Z,Y
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Then you can run your script on watchList1, making indexed
>
> >
>
> > >
>
> >
>
> > > reference
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > to the symbols in watchList2 as shown below.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Note, however, that I rearanged watchList1 to be in
>
> alphabetical
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > order before adding the indexed opposite symbols in
watchList2.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > It appears that AmiBroker iterates through the active
watchList
>
> in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > alphabetical order (regardless of the order that the symbols
>
> were
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > added to the list). So, you must ensure that the indexed
>
> opposites
>
> >
>
> > >
>
> >
>
> > > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchList2 will match their partner based on the assumption
>
> that
>
> >
>
> > >
>
> >
>
> > > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > partners were sorted before being processed by your script.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > If your lists are expected to be relatively unchanging, this
>
> may
>
> >
>
> > be
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > an acceptable bit of book keeping.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Buy = Sell = Short = Cover = 0;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Get opposites from second list, ordered as originally
>
> entered.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > list = CategoryGetSymbols( categoryWatchlis t, 2);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Get alphabetized index of current symbol from first list.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > index = status("stocknum" );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Extract opposite for the current symbol.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > opposite = StrExtract(list, index);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > _TRACE(Name( ) + " and " + opposite);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > SetForeign(opposite );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > // Do whatever you want with foreign opposite
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Mike
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
>
> <normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > thanks yes Im looking for something like this. In the end I
>
> have
>
> >
>
> > >
>
> >
>
> > > a
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > code that at the beginning designates two symbols.
>
> ticker1=ibm ,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > ticker2=ge for example. Then I run the code.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > The thing is, I have a few of them and I dont want to
>
> manually
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > enter them. Instead I was thinking of putting a couple of
>
> tickers
>
> >
>
> > >
>
> >
>
> > > per
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchlist. Then trying to call upon them by saying take each
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > watchlist and make first symbol in watchlist = ticker1 and
then
>
> >
>
> > 2nd
>
> >
>
> > >
>
> >
>
> > > =
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > ticker2.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Then run code. Then take watchlist 2 and do the same thing
>
> and
>
> >
>
> > >
>
> >
>
> > > run
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > code.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Is it possible to do that? How would I code that?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > --- On Wed, 12/10/08, Barry Scarborough <razzbarry@ ..>
wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > From: Barry Scarborough <razzbarry@ ..>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Subject: [amibroker] Re: scrolling through a watchlist
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > To: amibroker@xxxxxxxxx ps.com
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Date: Wednesday, December 10, 2008, 11:32 PM
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > I an not sure what you are looking for. This
>
> program
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > runs through a
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > watch list and processes the the symbols individually. You
>
> can
>
> >
>
> > do
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > all
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > sorts of things within SetForeign() and RestorePriceArrays(
);
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Barry
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _SECTION_BEGIN( "Using SetForeign") ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > SetChartOptions( 0, chartShowArrows | chartShowDates );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Filename = StrLeft(_DEFAULT_ NAME(),StrLen( _DEFAULT_
NAME())-
>
> 2)
>
> >
>
> > ;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _N(Title = filename + StrFormat(" - {{DATE}} {{VALUES}} "));
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // parameters
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > Watchlist = 10;
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > // create comma separated list of symbols in the watch list
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > list = CategoryGetSymbols( categoryWatchlist, watchlist );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > /*
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > this gets the symbol name and the for loop will process
every
>
> >
>
> > one
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > in
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > the watch list for each bar. In an auto trading program it
>
> will
>
> >
>
> > >
>
> >
>
> > > run
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > every time a tick is received
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > */
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > {
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > SetForeign(sym) ; // switches to the symbol array,
>
> OHLCVOi
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > /*
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > put your code here. You can create an include that will
>
> define
>
> >
>
> > >
>
> >
>
> > > the
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > parameters for each symbol you have optimized and
dynamically
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > switch
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > the parameters for the indicators. You can also dynamically
>
> >
>
> > >
>
> >
>
> > > switch
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > a different system for some symbols. Your imagination is the
>
> >
>
> > >
>
> >
>
> > > limit.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > */
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > RestorePriceArrays( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > }
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > _SECTION_END( );
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > --- In amibroker@xxxxxxxxx ps.com, jim fenster
>
> <normanjade@ ...>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > > If you have a code that works on two symbols, is it
>
> possible
>
> >
>
> > >
>
> >
>
> > > call
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > upon the first and second tickers in the watchlist without
>
> >
>
> > having
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > to
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > actually manually write the tickers? Like referring to them
>
> as
>
> >
>
> > >
>
> >
>
> > > 1st
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > and 2nd ticker in this specific watchlist. possible?
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>

3a.

Re: Off-Topic : recover lost file (Thanks : it is URGENT)

Posted by: "sumangalam" sumangalam@xxxxxcom   sumangalam

Thu Dec 18, 2008 7:07 pm (PST)

Thanks PFTrader,

I wish nobody else faces a situation like this, however for the
benefit of any other users, the following article may come handy in
future.

http://lifehacker. com/393084/ how-to-recover- deleted-files- with-free-
software

With regards

Sanjiv Bansal

--- In amibroker@xxxxxxxxx ps.com, "pftrader" <apforex@xxx > wrote:
>
> Try GlaryUtilities
> http://www.glaryuti lities.com/ gu.html?tag= download
>

4a.

Re: help for indicator and IIF issue

Posted by: "Paolo Cavatore" pcavatore@xxxxxxcom   pcavatore

Fri Dec 19, 2008 1:22 am (PST)

Yes, that's it...thanks for the smart hint

p

--- In amibroker@xxxxxxxxx ps.com, "Mike" <sfclimbers@ ...> wrote:
>
> Is this what you want?
>
> Series1 = MA(Close, 50);
> Series2 = ValueWhen(BarIndex( )%3 == 0, Series1);
> Plot(Series1, "Smooth", colorRed);
> Plot(Series2, "Steps", colorBlue);
>
> The above will give you a series like the following:
>
> 20,20,20,30, 30,30,...
>
> Mike
>
> --- In amibroker@xxxxxxxxx ps.com, "Paolo Cavatore" <pcavatore@>
> wrote:
> >
> > I've got a very simple indicator but can't get proper afl code.
> >
> > I want to plot an indicator equal to MA(C, 50) on day1 - let's
say
> 20
> > $. For the following 2 days it has to be the same - 20$.
> > On day 4 it is equal to MA(C, 50) again - let's say 30$ - and
> remain
> > at 30$ for the following 2 days again.
> > Its shape would then be similar to a staircase.
> >
> > In short the indicator should be equal to MA(C, 50) every four
days
> > and be the same for the remaining 3 days.
> >
> > I tried to code it as follow but it doesn't work due to the IIF
> logic:
> >
> > MyIndicator = IIf(BarsSince( MA(C, 50) != Ref(MA(C, 50), -1)) > 3,
MA
> > (C, 50), Ref(Ma(C, 50), -1));
> >
> > Anyone can help?
> >
> > regards,
> >
> > paolo
> >
>

5.

How to draw indicator in time lag?

Posted by: "maximoff_max" mrmax@xxxxxxxru   maximoff_max

Fri Dec 19, 2008 1:31 am (PST)

Hi all!

I try to make my own trading system and i need help.
I want to recalculate my indicator evry day.
Example:
I have 3 periods ROC (on 5 Min) and i want to ask AmiBroker start
calculate this indicator at 9:00 Morning and finish at the end of day

I try to do it but get mistake :-(

Thanks
Max

6a.

Re: Synergy trading system

Posted by: "Howard B" howardbandy@gmail.com   howardbandy

Fri Dec 19, 2008 1:34 am (PST)

Greetings all --

Since my name was mentioned in this thread ----

Books and articles have copyright protection as soon as they are expressed.
When I begin to write, my first draft has implicit protection. When I have
the book printed and distributed, I include the statement that I am
explicitly retaining the copyright and claiming protection. The whole book
is copyrighted, even though it may contain information that is not original
with me. Among other things, the copyright prohibits some person from
redistributing or reselling my book, or any portion thereof, without my
permission. (Whether for profit or not is not an issue. Certain "fair use"
is exempt.) There is no doubt that some of the AFL code used as examples
was well known before that code appeared in my book. But there is other
code that is original with me. If the entire code from my book appears on a
website for sale (as it does), that is a violation of International
Copyright laws. And I could bring a law suit and would win if I was willing
to pay the price in both time and money. The cost to me would be high, the
award probably low, and the likelihood of my collecting very low. If
someone posts the simple moving average crossover example, as was done in
this thread, or other examples that were well known before my book was
published, I would be foolish to complain and very foolish to bring a law
suit. Rather, in cases such as this, I benefit by having my work
referenced. In fact, I have answered several questions posted to this forum
by posting code included in my book in my response. That does not
relinquish my protection under the copyright laws and it does not give
permission to anyone else to republish it without my permission.

The point is -- If someone claims copyright protection for their code, no
one has a right to republish that material without the copyright holder's
permission unless they can show that the same information existed prior to
that specific copyright claim in an uncopyrighted form. The material being
protected may be worthless, but it is still protected. If the material is
protected under copyright but published on the copyright holder's web site,
you may post a URL link to his or her page, but you may not copy the
information and republish it without permission.

As for "should have published electronically" -- Think carefully about your
business plan when you form your own publishing company. It is much more
complex than first meets the eye.

Thanks for listening,
Howard

On Tue, Dec 16, 2008 at 5:48 AM, Paul Ho <paul.tsho@xxxxxx com> wrote:

> Amikid
> send me a private email, saying what you want done, ie indicator, system or
> exploration .....I might be able to provide some free afl consulting
> /paul.
>
> ------------ --------- ---------
> *From:* amibroker@xxxxxxxxx ps.com [mailto:amibroker@xxxxxxxxx ps.com] *On
> Behalf Of *pdevadasnayak
> *Sent:* Tuesday, 16 December 2008 11:27 PM
> *To:* amibroker@xxxxxxxxx ps.com
> *Subject:* [amibroker] Re: Synergy trading system
>
>
> My sincere Thanks to Barry Scarborough, Brian,"LB" & Judith for setting
> the controversy to "rest'
>
> My only problem here was I could not find "volatility Bands" in
> Amibroker AFL library.
>
> I would like to know
>
> 1) Has "13" RSI got to be smoothed twice once with 2 MAV & then With 7 MAV
>
> 2) Volatility bands what should be the Percentages above & below the
> Parameters 34
>
> Since I could Not handle AFL coding myself I asked this question.I am
> new to Amibroker.My intention was not & is not to hurt anyone.
>
> Regards
>
> Amikid
>
> --- In amibroker@xxxxxxxxx ps.com <amibroker%40yahoog roups.com> , "Barry
> Scarborough" <razzbarry@x ..>
> wrote:
> >
> > Wow guys! I can remember such a malicious thread since I started
> > posting here in 2003. Waz up?
> >
> > 1. There is no copyright violation when a user can reference an open
> > item. To say it is would be as silly as saying that checking a book
> > out at the library is a copyright violation. Techie did not copy it.
> > He just posted a link to it and asked if the concept could be coded
> > in AFL. Anything written down is automatically copyrighted. So you
> > can't copy it and claim it is yours. But you can use the intellectual
> > property to your benefit. We do that with text books and
> > encyclopedias all the time. And we do that with AFL examples. They
> > are all copyrighted as soon as they are posted.
> >
> > 2. This paper is in the public domain. No password or user id
> > required. Hardly a highly protected item. If you can find something
> > on the internet that is in the public domain it is not illegal to use
> > it. Even patents can be used by individuals. You just can use the
> > idea in something you sell without paying a royalty.
> >
> > 3. Where is there any indication anyone is trying to steal something?
> > Nothing was stolen but maybe a little sanity lost. It is kinda hard
> > to steal something that is provided free.
> >
> > 4. Techie had a valid question, can this be done in AB. If anyone
> > either wanted to buy AB or find out if something can be done why not
> > ask?
> >
> > 5. No there is nothing in the paper that I can see that can't be done
> > in AB and would be fairly straight forward. I did not see all the
> > formulas but I just took a quick peek.
> >
> > 6. Nothing stupid or insulting here dingo. Did a bee fly up your nose
> > or what?
> >
> > Bed time, maybe for more than just me.
> >
> > Kind thoughts,
> > Barry
> >
> > --- In amibroker@xxxxxxxxx ps.com <amibroker%40yahoog roups.com> ,
> "techie11111" <techie11111@ >
> > wrote:
> > >
> > > Can anyone code the AfL for traders dynamic Index or synergy trading
> > > system
> > >
> > > The link I got from internet is posted here
> > >
> > > www.forexmt4. com/_MT4_ Systems/Traders% 20Dynamics/ TDI_1.pdf
> > >
> > > Regards
> > >
> > >
> > > Amikid
> > >
> >
>
>
>
7a.

Re: y-axis value for crosshair

Posted by: "reinsley" reinsley@xxxxxxfr   reinsley

Fri Dec 19, 2008 1:35 am (PST)


Place the cross over a bar or candle. A bubble windows will show Y value.

BR

Tim a écrit :
>
> Hi Dennis,
> Is there anyway you know of to get the X-Y axis showing on the
> crosshairs? Personally, I prefer that mode of presentation. Thank you.
>
> Kindest regards,
>
> Tim
>
> --- In amibroker@xxxxxxxxx ps.com <mailto:amibroker% 40yahoogroups. com>,
> Dennis Brown <see3d@xxx> wrote:
> >
> > The X and Y cursor values are shown at the bottom of the window.
> >
> > BR,
> > Dennis
> >
> > On Dec 15, 2008, at 2:07 PM, r_terbush wrote:
> >
> > > How do I turn on the y-axis value for the crosshair? Surprised that I
> > > cannot find any discussion of this in the usermanual, google hits,
> > > etc.
>
>
> .
>
>

8a.

Re: ADR Index and IB TWS

Posted by: "Keith McCombs" kmccombs@xxxxxxxxxcom   keithmccombs

Fri Dec 19, 2008 1:36 am (PST)

Barry --
I contacted TWS and received the following explanation.

"/Amibroker historical data equates Trader Workstation (TWS) charting
information. Therefore, Amibroker backfill messages are identical to the
TWS charting display. If the Chart feature in TWS is not receiving data
for the ADR@xxxx INDEX contract, then it is impossible to obtain the
same information through any API program.

For further investigation, I tried requesting ADR@xxxx IND and the data
is not available. Some of the indexes are not available for backfill
data, and ADR is one of them unfortunately.

Before requesting data in Amibroker, first you need to navigate to the
TWS and enter the specified contract then open a charting window. If you
are successful in requesting backfill data in TWS, then you should able
to obtain the same historical data through the API./"

Thanks for your help.
-- Keith

Barry Scarborough wrote:
>
> I tried ADR-AMEX-IND this morning and could not back fill it. Same
> error message as last night. But I let it run and the data is being
> received and filling the chart.
>
> I guess back fill is a question for TWS support.
>
> Barry
>
> --- In amibroker@xxxxxxxxx ps.com <mailto:amibroker% 40yahoogroups. com>,
> "Barry Scarborough" <razzbarry@x ..>
> wrote:
> >
> > I tried and get the same error. If you place your cursor on the
> green
> > CONN IB bar in the lower right the last message will be displayed.
> The
> > message I get is Data service error message, not data returned. At
> > times this happens for no apparent reason. Wait until the market
> opens
> > tomorrow and see if it works then. Watch to see if the bars are
> being
> > updated in real time, then try to back fill.
> >
> > Barry
> >
> > --- In amibroker@xxxxxxxxx ps.com
> <mailto:amibroker% 40yahoogroups. com>, Keith McCombs <kmccombs@> wrote:
> > >
> > > I just recently got AB working with IB controller and TWS, 1
> minute
> > > data. I cannot load ADR-AMEX-IND. Whenever I try, an error or
> > warning
> > > message is displayed, but lasts for such a short time that I am
> > unable
> > > to read it. Also, I can view the chart on TWS, so I'm pretty
> sure I
> > am
> > > using the correct symbol.
> > >
> > > However, I have no problem with SPX-CBOE-IND or any of the
> *stocks* I
> > > have tried so far.
> > >
> > > Any help is greatly appreciated.
> > > -- Keith
> > >
> >
>
>
9.

Plot higher Timeframe EMA on 1M chart

Posted by: "Haresh Patel" hareshbhaip@yahoo.com   hareshbhaip

Fri Dec 19, 2008 5:18 am (PST)

Is it possible to PLOT 5min and 15Min 200bars EMA on 1Min Chart?

Also want to Draw the colorfull Area of Previous Hour and Current Hour.

10.

PlotText in a loop

Posted by: "reinsley" reinsley@xxxxxxfr   reinsley

Fri Dec 19, 2008 7:25 am (PST)

Hi,

Can somebody help me to correct this formula ?

I'd like to write the X value of the dot line just once, at the end of
each line.

Thank you for the help

Best regards

//PIVOTS LEVELS

// turning points
tn = Now();
_TRACE("**** ********* ********* *Time = "+tn);

top = C==HHV(C,3);
bot = C==LLV(C,3);

topH = ValueWhen(top, C);
botL = ValueWhen(bot, C);

GraphXSpace= 10;

col = IIf( Close > Ref( Close, -1 ), colorGreen, colorRed );
Plot( Close,"\nCl" , colorBlack, styleCandle );

Plot( topH, "", colorRed, styleDots+styleNoLi ne );
Plot( botL, "", colorGreen, styleDots+styleNoLi ne );

_N(Title = "PIVOTS LEVELS - " + StrFormat("{ {NAME}} - {{INTERVAL}}
{{DATE}} \nOp %g \nHi %g \nLo %g {{VALUES}}", O, H, L ));

for( i = 0; i < BarCount; i++ )
{
if( top [i] ) PlotText( "" + botL[ i ], i, botL[ i ], colorGreen );
if( bot [i] ) PlotText( "" + topH[ i ], i, topH[ i ], colorRed );
}

11a.

Accessing data from time frame lesser than selected chart time inter

Posted by: "nagkiran_k" k.nagakiran@gmail.com   nagkiran_k

Fri Dec 19, 2008 7:57 am (PST)

I have a database with 1-min data and selected the time interval as
hourly. so, all the built-in arrays are compressed accordingly but the
problem is i am not able to access 30-min data from the same AFL to
display in commentary/interpre ation using
TimeFrameGetPrice( "0",in5Minute* 6). Its always returning the hourly data.

Is it possible to access the data in lower-time frame in
commentary/interpre tation while the chart interval is set to higher
time-frame?

11b.

Re: Accessing data from time frame lesser than selected chart time i

Posted by: "Tomasz Janeczko" groups@xxxxxxxxxxcom   amibroker

Fri Dec 19, 2008 8:52 am (PST)

It is clearly explained in the guide
http://www.amibroke r.com/guide/ h_timeframe. html

"Please note that you can only compress data from shorter interval to longer interval. So when working with 1-minute data you can
compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar
way if you have only EOD data you can not access intraday time frames."

So, your chart needs to be using 30 minute interval or less if you want interpretation using 30 min data.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "nagkiran_k" <k.nagakiran@ gmail.com>
To: <amibroker@xxxxxxxxx ps.com>
Sent: Friday, December 19, 2008 4:57 PM
Subject: [amibroker] Accessing data from time frame lesser than selected chart time interval

>I have a database with 1-min data and selected the time interval as
> hourly. so, all the built-in arrays are compressed accordingly but the
> problem is i am not able to access 30-min data from the same AFL to
> display in commentary/interpre ation using
> TimeFrameGetPrice( "0",in5Minute* 6). Its always returning the hourly data.
>
> Is it possible to access the data in lower-time frame in
> commentary/interpre tation while the chart interval is set to higher
> time-frame?
>
>
> ------------ --------- --------- ------
>
> **** IMPORTANT ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> ************ *********
> TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
> ************ *********
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroke r.com/devlog/
>
> For other support material please check also:
> http://www.amibroke r.com/support. html
>
> ************ ********* ********* ***
> Yahoo! Groups Links
>
>
>

12.

Current bar value in the array?

Posted by: "r_terbush" randy@xxxxxxxxorg   r_terbush

Fri Dec 19, 2008 8:46 am (PST)

Need a clarification from the manual. The manual does not state this
clearly enough for my little brain.

Is the current bar (ie. the most recent bar) close[barcount - 1]?

appreciate the help

Recent Activity
Visit Your Group
Yahoo! News
You won't believe
it, but it's true
Yahoo! Finance
Guides, news,
advice & more.
Ads on Yahoo!
Reach customers
searching for you.
Need to Reply?
Click one of the "Reply" links to respond to a specific message in the Daily Digest.
Create New Topic | Visit Your Group on the Web
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************


Add more friends to your messenger and enjoy! Invite them now.

__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___