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

RE: [amibroker] COM Object Statement Works One Place but Not another



PureBytes Links

Trading Reference Links

d  
 
Like I said in the middle of the note, when I copy and put the call to the
procedure OUTSIDE a loop structure, it gives the error.  The procedure is
the procedure and works if called from within a loop and the scan is running
against all symbols. (See below for complete code)
 
I have tried numerous variations, using the procedure shown in the code
picture, but nothing works.  I just completed a "pure" ATC, no loops  AND NO
PROCEDURE, and it worked.
 
The CompositeLoad procedure is a very versatile approach and works well for
updating industry and watchlists and keeping them all numbered and named
easily.  It is puzzling why it does not seem to work when you want to create
just a "simple" ATC using the CompositeLoad procedure.
 
For anyone interested, I will copy the entire code with which I update
TC2005 standard industries, as well as various Watchlists in which I have
different industry groupings.  Note the complex naming conventions in order
to keep everything in proper order when listed in ASCII order in the symbol
tree.  (If anyone just copies this in, it likely will not work correctly
because of the watchlist locations where I have my other industry
groupings.)
 
Again, thanks to Dan Clark for the code on which this is all based.  (I wish
he would jump in a make some comment on this anomoly.)
 
Ken
 
======================================================================
 
//  Z_LoopCode_ATCS3.afl  KSC   8/13/2006
//  Credit to Dan Clark for code and concepts
Filter=1;
 
AB = CreateStaticObject("Broker.Application");
 
//Procedure to add to Composite values
 
procedure CompositeLoad(Sym, SymName, CloseVal, OpenVal, HighVal, LowVal,
VolVal, 
 OpenIntVal, ATCFlags, TargetWLNbr)
   {
   //Add To Composite
   AddToComposite(CloseVal,   Sym, "C", ATCFlags);
   AddToComposite(OpenVal,    Sym, "O", ATCFlags);
   AddToComposite(HighVal,    Sym, "H", ATCFlags);
   AddToComposite(LowVal,     Sym, "L", ATCFlags);
   AddToComposite(VolVal,     Sym, "V", ATCFlags); 
   AddToComposite(OpenIntVal, Sym, "I", ATCFlags); 
   
   //Modify Names
   cs        = AB.Stocks(Sym) ;                      
   cs.FullName = SymName          ;                 
 
   // Add to Watchlists
   if (TargetWLNbr != 0)
       CategoryAddSymbol(Sym, categoryWatchlist, TargetWLNbr); 
   }
   
//AddToCompositeFlags
atcCurrentFlags =  atcFlagResetValues + atcFlagCompositeGroup +
atcFlagEnableInExplore;
//Load composite symbols and add to watchlist
 
NumOfIndustry = 216; // or the actual number (max 256)
for(w=1;w<NumOfIndustry;w++) // note that the loop starts from 0, not 1
 {
  if(IndustryID() == w) 
  {
   if(w<10) Sym = "~Z00"+w;
   if(w>9 AND w<100) Sym = "~Z0"+w;
   if(w>99) Sym = "~Z"+w;
   SymName = CategoryGetName(categoryIndustry,w);
   //CompositeLoad(Sym, SymName, CloseVal, OpenVal, HighVal, LowVal, VolVal,
OpenIntVal, ATCFlags, TargetWLNbr)
   CompositeLoad(Sym, SymName, C, O,H,L,V, 1, atcCurrentFlags, 8);
   
   //Get Adv AND Decliners
   Up = IIf(C>Ref(C,-1),1,0);
   Dn = IIf(C<Ref(C,-1),1,0);
   if(w<10) Sym = "~UD00"+w;
   if(w>9 AND w<100) Sym = "~UD0"+w;
   if(w>99) Sym = "~UD"+w;
   SymName = CategoryGetName(categoryIndustry,w);
   CompositeLoad(Sym, SymName, 0,0,Up,Dn,0, 1, atcCurrentFlags, 9);
 
   //Get Industry Advancing Decline Volumes
   Up = IIf(C>Ref(C,-1),V,0);
   Dn = IIf(C<Ref(C,-1),V,0);
   if(w<10) Sym = "~UV00"+w;
   if(w>9 AND w<100) Sym = "~UV0"+w;
   if(w>99) Sym = "~UV"+w;
   SymName = CategoryGetName(categoryIndustry,w);
   CompositeLoad(Sym, SymName, 0,0,Up,Dn,0, 1, atcCurrentFlags, 10);
 

  }
 }
 
//   -------------------- Update Watchlist Industries --------------------
 
NumOfWL = 53; // or the actual number (max 256)
for(w=11;w<NumOfWL;w++) // note that the loop starts from 0, not 1
 {
  if(InWatchList(w)) 
  {
   if((w-10)<10)        Sym = "~Z0"+(w-10);
   if((w-10)>9 AND (w-10)<42)    Sym = "~Z"+(w-10);
   if((w-10)>41 AND (w-10)<53)    Sym = "~Z"+(w-2);
   SymName = CategoryGetName(categoryWatchlist,w);
   //CompositeLoad(Sym, SymName, CloseVal, OpenVal, HighVal, LowVal, VolVal,
OpenIntVal, ATCFlags, TargetWLNbr)
   CompositeLoad(Sym, SymName, C, O,H,L,V, 1, atcCurrentFlags, 53);
   
   //Get Adv AND Decliners
   Up = IIf(C>Ref(C,-1),1,0);
   Dn = IIf(C<Ref(C,-1),1,0);
   if((w-10)<10)        Sym = "~UD0"+(w-10);
   if((w-10)>9 AND  (w-10)<42)    Sym = "~UD"+(w-10);
   if((w-10)>41 AND (w-10)<53)    Sym = "~UD"+(w-2);
 
   SymName = CategoryGetName(categoryWatchlist,w);
   CompositeLoad(Sym, SymName, 0,0,Up,Dn,0, 1, atcCurrentFlags, 54);
 
   //Get Watchlist Advancing Decline Volumes
   Up = IIf(C>Ref(C,-1),V,0);
   Dn = IIf(C<Ref(C,-1),V,0);
   if((w-10)<10)        Sym = "~UV0"+(w-10);
   if((w-10)>9 AND (w-10)<42)    Sym = "~UV"+(w-10);
   if((w-10)>41 AND (w-10)<53)    Sym = "~UV"+(w-2);
 
   SymName = CategoryGetName(categoryWatchlist,w);
   CompositeLoad(Sym, SymName, 0,0,Up,Dn,0, 1, atcCurrentFlags, 55);
 
  }
 }
 
Buy=1;

  _____  

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of dingo
Sent: Tuesday, August 15, 2006 11:02 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] COM Object Statement Works One Place but Not
another


Well, with fresher eyes I see that I was wrong about cs not being an object.
It IS.  My bad. 
 
I dunno what's going on unless there's something going on in the code that's
not visibile which almost has to be the case.
 
d
 
 


  _____  

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Ken Close
Sent: Tuesday, August 15, 2006 9:05 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] COM Object Statement Works One Place but Not
another


The picture shows side by side of two formulas.  The one on the right passes
syntax and runs.  The one on the left is copied from the one on the right
and shows the error message from check Syntax.  Marks suggestion to "ignore"
and just run it does not fly because it will not run.  
 
Another difference is the one on the right applies the procedure thru a lopp
driven off of a for statement (you can see the top of the loop in lower
right pane).  In the one on the left, I just needed one ATC so just have a
normal ATC statement below the procedure code.  Hmmmm.  I copied the entire
code from the right (copied at bottom of this message). No syntax error.  I
then copied just the ATC statement and Sym and SymName above the loop, and
get the error.  What is going on with the loop that avoids the error if the
procedure call is within the for loop?
 
The solution seems to be to provide a loop to call the procedure, but why is
this needed.......?
 
ken