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

[amibroker] question about displaying numeric values



PureBytes Links

Trading Reference Links

hi,

I wrote some code, shown below. It works fine but for some reason it 
finds a sell at the last day, always. Also in the window of display 
it shows a sell at the open price. To investigate what is going on I 
wanted to create some output to the "Interpretation" window. The code 
is loaded in the "Indicator Builder" but even though it must go 
inside these "if" statements I do not get any output. Why is that?

If somebody has a clue why I get a sell at the last bar that would be 
very much appreciated as well,

regards, Ed


------ the code

// high threshold in %
hit = 2;
// low threshold in %
lot = 20;
// max duration of trade
maxdur = 40;

// generate buy signals
Buy = Cross(RSI(),30);

// buy the next day
Buynd = Ref(Buy,-1);

//
buyprice = Open; sellprice = buyprice; sellprice = 0;
sell = buy; sell = 0;

for (i = 0; i < BarCount; i++) {

	// if a buy signal is found then search for an sell position
	if (Buynd[ i ] == 1) {	
	
		// set the low + high thresholds for the buy signal
		thigh = buyprice[i] + buyprice[i]*(hit/100);
		tlow = buyprice[i]  - buyprice[i]*(lot/100);
		
		// find a sell position + price for every individual 
buy signal
		for (j = i; j < BarCount; j++) {
			

			if ((j - i) > maxdur) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = c[j];
				j = BarCount-1;	
				"a" + writeval(i,1.2);
			
			}
		
			if (h[j] > thigh) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = thigh;
				j = BarCount-1;
				"b" + writeval(i,1.2);
			
			}
			
			if (l[j] < tlow) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = tlow;
				j = BarCount-1;
				"c" + writeval(i,1.2);
			
			}
			
			if (o[j] > thigh) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = open[j];
				j = BarCount-1;
				"1" + writeval(i,1.2);
			
			}
			
			if (o[j] > thigh AND h[j] > thigh) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = open[j];
				j = BarCount-1;
				"2" + writeval(i,1.2);
			}
			
			if (o[j] < tlow) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = open[j];
				j = BarCount-1;
				"3" + writeval(i,1.2);
			
			}		
			
			if (o[j] < tlow AND l[j] < tlow) {
			
				Sell[ j ] = 1;
				SellPrice[ j ] = open[j];
				j = BarCount-1;
				"4" + writeval(i,1.2);
			}			
			
		
		}
	
	}

}


// for the indicator builder window
Plot(C,"",1,64);
PlotShapes(shapeDownArrow*Sell,colorRed,0,SellPrice);
PlotShapes(shapeUpArrow*Ref(Buy,-1),colorGreen,0,BuyPrice);
title=name()+ ", O:"+writeval(o)+ ", H:"+writeval(h)+ ", L:"+writeval
(l)+ ", C:"+writeval(c);

// for the automatic analysis window
Filter = 1;
AddColumn(Buy,"buy");
AddColumn(Buynd,"buynd");
AddColumn(BuyPrice,"buyprice");
AddColumn(Sell,"sell");
AddColumn(SellPrice,"sellprice");


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/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/