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

[amibroker] Problem with Cell-Coloring feature of AddColumn inside AFL Loops



PureBytes Links

Trading Reference Links

Hello,

I have an exploration that works very well (thanks to some help with 
the looping construct from TJ), however, because it is a large 
exploration, I wanted to highlight certain results conditionally to 
mke them easier to locate.

The problem is, as soon as I add the arguments for the cell color, I 
get a system crash

This works flawlessly:
AddColumn(x=IIf(interesting, netpct,0),"intNetPct"+fac, 1.2);

When I add this to it:

AddColumn(x=IIf(interesting, netpct,0),"intNetPct"+fac, 1.2, 
colorDefault, y=IIf(netpct >= 10, colorGreen, colorDefault));

...I get the following system crash (on either "Check" or "Explore"):

(CRASH DUMP):
-------------------------------------------------------------------
AmiBroker version 4.44.0
 ( cooltool.dll 4.44.0,  mfc42.dll 6.0.8665,  msvcrt.dll 6.1.8924 )

Microsoft Windows 2000 version 5.0 (Build 2195)
Service Pack 2.0
Common Controls: 5.81

Unhandled exception
Type:	CSysException
Code:	c0000005
Description:	ACCESS VIOLATION
Address:	447456

	AddColumn(x=IIf(interesting, netpct,0),"intNetPct"+fac, 1.2, 
colorDefault, IIf(netpct >= 10, colorGreen, colorDefault));

}
^

(occurred during AFL formula execution)

AFL Parser status:
Processing stage: EXECUTE
Formula ID: 0 ()
Action 5 (BACKTEST)

Additional information:

Number of stock loaded: 25389
Currently selected stock: VNWI
Number of quotes (current stock): 925

Workspace:
Data source = (default), Data local mode = 0, NumBars = 2600

Preferences:
Data source = QP2 , Data local mode = 1, NumBars = 2600

Command history:
2828 - Shows Analyser - a tool to test systems & explore market--Auto-
Analyser

Cache manager stats:
Number of list elements: 3
Number of map elements: 3
Hash table size: 5987

Memory status:
  MemoryLoad: 46 %
  TotalPhys:       261668K  AvailPhys:       139768K
  TotalPageFile:  1288600K  AvailPageFile:  1111620K
  TotalVirtual:   2097024K  AvailVirtual:   1874952K

Last Windows message:
HWnd:	0x604b4
Msg:	0x0110
wParam:	0x000604b6
lParam:	0x00000000

-------------------------------------------------------------------

The complete source code:

-------------------------------------------------------------------

per = 65;
MAvol = MA(V, per);
Minvol = 100000;
MinPrice = 4.00;
MaxPrice = 20.00;
MinIrc = 2;
R1 = ATR(per);
irc = (r1/C)*100;
L1 = Ref(L, -1);
C2 = Ref(C, -2);
Filter = (BuyPrice >= MinPrice) AND (BuyPrice <=MaxPrice) AND (V >= 
Minvol) AND (MAvol >= Minvol) AND (irc >= MinIrc);

AddTextColumn(FullName(),"Name");
AddColumn(MarketID(0), "Mkt", 1.0);
AddTextColumn(MarketID(1), "Market");
AddColumn(SectorID(0), "Sectr", 1.0); 
AddTextColumn(SectorID(1), "Sector"); 
AddColumn(IndustryID(0), "Ind", 1.0);
AddTextColumn(IndustryID(1), "Industry");
AddColumn(C, "Price", 1.2);
AddColumn(MAvol/1000, "Vol/K", 1.0);
AddTextColumn(Name(), "Ticker");
AddColumn(R1, "1R", 1.2);
AddColumn(irc, "1R/C", 1.2);
AddColumn(per, "per", 1.0);

totalWins = 0;
totalLosses = 0;
totalWinPct = 0;
totalNetPct = 0;
totalInt = 0;

totalRawWins = 0;
totalRawLosses = 0;
totalRawWinPct = 0;
totalRawNetPct = 0;
totalRawInt = 0;


for( i=870; i<=970; i++ ) {
	fac=i*.001;
	filled=(L1 < C2* fac);
	profitable =((O/(C2* fac))-1 > 0.01);
	profitPct=((O/(C2* fac)-1)*100);
	trades=(Sum(IIf((filled) AND (Filter), 1, 0), per));
		frequent=(trades>=5);
	wins=(Sum(IIf((filled) AND (Filter) AND (frequent) AND 
(profitable), 1, 0), per));
        rawWins=(Sum(IIf((filled) AND (Filter) AND (profitable), 1, 
0), per));
	Losses = trades-wins;
        rawLosses = trades-rawWins;
	winpct=(wins/trades)*100;
        rawWinpct=(rawWins/trades)*100;
		winalot= winpct>=65;
        rawWinalot= rawWinpct>=65;
		netpct=(Sum(IIf((filled) AND (Filter) AND (frequent) 
AND (winalot), profitPct,0), per));
	rawNetPct=(Sum(IIf((filled) AND (Filter) AND (rawWinalot), 
profitPct,0), per));
	interesting = (netpct >= 10) AND (frequent) AND (winalot);
rawInteresting = (rawNetpct >= 10) AND (winalot);
	totalWinPct = totalWinPct+winpct;
totalRawWinPct = totalRawWinPct+RawWinpct;
	totalNetPct = totalNetPct+netpct;
totalRawNetPct = totalRawNetPct+rawNetPct;
	totalInt = totalInt+interesting;
totalRawInt = totalRawInt+rawInteresting; 
		totalWins = totalWins+wins;
totalRawWins = totalRawWins+rawWins;
		totalLosses = totalLosses+Losses;
totalRawLosses = totalRawLosses+rawLosses;
		
	//score=IIf(frequent,(winpct*netpct)/100,
(winpct*netpct)/1000);
	if(i%10==0){
	AddTextColumn(Name(),"Ticker");
	}

	//AddColumn(trades,"#Trades"+fac,1.0);
	//AddColumn(wins, "#Wins"+fac, 1.0);
	//AddColumn(winpct,"winpct"+fac, 1.2);
	AddColumn(netpct,"netpct"+fac, 1.2);
	AddColumn(x=IIf(interesting, netpct,0),"intNetPct"+fac, 1.2, 
colorDefault, IIf(netpct >= 10, colorGreen, colorDefault));


}
AddColumn(totalWins,"TotalWins", 1.2);
AddColumn(totalRawWins,"TotalRawWins", 1.2);
AddColumn(totalLosses,"TotalLosses", 1.2);
AddColumn(totalRawLosses,"TotalRawLosses", 1.2);
AddColumn(totalWinPct,"TotalWinPct", 1.2);
AddColumn(totalRawWinPct,"TotalRawWinPct", 1.2);
AddColumn(totalNetPct,"TotalNetPct", 1.2);
AddColumn(totalRawNetPct,"TotalRawNetPct", 1.2);
AddColumn(totalInt,"TotalInt", 1.2);
AddColumn(totalRawInt,"TotalRawInt", 1.2);

--------------------------------------------------------------------

My goal here is just to highlight cells of interest in this rather 
large exploration.

I troubleshot so far by creating a very simple one line exploration 
and then adding the cell coloring arguments to this small, simple 
exploration.  The result was, it still crashed the system as soon as 
I added the cell-coloring arguments and hit "Check" or "Explore."

So then, I tried the code from the example in the AB help:

AddColumn( Close, "Close", 1.2 );
AddColumn( MACD(), "MACD", 1.4 , IIf( MACD() > 0, colorGreen, 
colorRed ) );
AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf( Close 
< 10, colorLightBlue, colorDefault ) );

....which worked by itself just fine, but when I copied this same 
code to my exploration, again it crashed.


...Finally, I moved the above code to another location in my 
exploration which was outside the loop, and then it worked without 
crashing, but the problem now is, I need my code to work inside the 
loop to get the information I am seeking.

So... Is this a known problem? Does the cell-coloring feature of add-
column not work inside AFL loops?  Please forgive me if I have 
overlooked any obvious things, or not tried hard enough on my own, 
but I seem to have hit a wall here.  This issue seems beyond my 
current AB knowledge and skill.

Any suggestions  for further troubleshooting appreciated.


Thanks,

Nick Molchanoff








------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs from home.
Over 14,500 titles. Free Shipping
& No Late Fees. Try Netflix for FREE!
http://us.click.yahoo.com/mk9osC/hP.FAA/3jkFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/