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

[amibroker] global parameters



PureBytes Links

Trading Reference Links

hi,

I hope I'm not overlooking something stupid here. Inside a procedure 
I defined the global variables:

global Sell;
global SellPrice;

Later I added:

global SellPriceAtIndexOfBuy;

which would give me the sellprice but now at the index of the buy. 
However SellPriceAtIndexOfBuy remains empty. I have the feeling I am 
missing some fundamental AFL characteristic here. The code is printed 
below. It is basicly a "j-loop" within an "i-loop". Hope somebody can 
clear the mist for me,

regards, Ed




-----> the code of the procedure. Hope it doesn't look too messy once 
it is printed in Yahoo .....

procedure SellSystem001_p
(Buy,BuyPrice,open,high,low,close,hit,lot,maxdur) 
{

// Edward Pottasch, Okt 2003
// hit: high threshold
// lot: low threshold
// maxdur: maximum number of days for a trade

global Sell;
global SellPrice;
global SellPriceAtIndexOfBuy;

SellPrice = BuyPrice; SellPrice = 0; Sell = Buy; Sell = 0;
SellPriceAtIndexOfBuy = BuyPrice; SellPriceAtIndexOfBuy = 0;

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

	// if a buy signal is found then search for an sell position
	if (Buy[ 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];
				SellPriceAtIndexOfBuy[ i ] = C[j];
				j = BarCount-1;	
				printf("a: %f \n",1);
				printf("i: %f \n",i);
				printf("j: %f \n",j);
				printf("bp: %f \n",BuyPrice[ i ]);
				printf("sp: %f \n",SellPrice[ j ]);
				printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
			
			} else if (H[j] > thigh) {
			
					Sell[ j ] = 1;
					SellPrice[ j ] = thigh;
					SellPriceAtIndexOfBuy[ i ] = 
thigh;
					j = BarCount-1;
					printf("b: %f \n",2);
					printf("i: %f \n",i);
					printf("j: %f \n",j);
					printf("bp: %f \n",BuyPrice[ 
i ]);
					printf("sp: %f \n",SellPrice[ 
j ]);
					printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
			
			} else if (L[j] < tlow) {
			
					Sell[ j ] = 1;
					SellPrice[ j ] = tlow;
					SellPriceAtIndexOfBuy[ i ] = 
tlow;
					j = BarCount-1;
					printf("c: %f \n",3);
					printf("i: %f \n",i);
					printf("j: %f \n",j);	
				
					printf("bp: %f \n",BuyPrice[ 
i ]);
					printf("sp: %f \n",SellPrice[ 
j ]);
					printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
			
			} else if (O[j] > thigh) {
			
					Sell[ j ] = 1;
					SellPrice[ j ] = Open[j];
					SellPriceAtIndexOfBuy[ i ] = 
Open[j];
					j = BarCount-1;
					printf("d: %f \n",4);
					printf("i: %f \n",i);
					printf("j: %f \n",j);
					printf("bp: %f \n",BuyPrice[ 
i ]);
					printf("sp: %f \n",SellPrice[ 
j ]);
					printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
			
			} else if (O[j] > thigh AND H[j] > thigh) {
			
					Sell[ j ] = 1;
					SellPrice[ j ] = Open[j];
					SellPriceAtIndexOfBuy[ i ] = 
Open[j];
					j = BarCount-1;
					printf("e: %f \n",5);
					printf("i: %f \n",i);
					printf("j: %f \n",j);	
				
					printf("bp: %f \n",BuyPrice[ 
i ]);
					printf("sp: %f \n",SellPrice[ 
j ]);
					printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
					
			} else if (O[j] < tlow) {
			
					Sell[ j ] = 1;
					SellPrice[ j ] = Open[j];
					SellPriceAtIndexOfBuy[ i ] = 
Open[j];
					j = BarCount-1;
					printf("f: %f \n",6);
					printf("i: %f \n",i);
					printf("j: %f \n",j);
					printf("bp: %f \n",BuyPrice[ 
i ]);
					printf("sp: %f \n",SellPrice[ 
j ]);
					printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
			
			} else if (O[j] < tlow AND L[j] < tlow) {
			
					Sell[ j ] = 1;
					SellPrice[ j ] = Open[j];
					SellPriceAtIndexOfBuy[ i ] = 
Open[j];
					j = BarCount-1;
					printf("g: %f \n",7);
					printf("i: %f \n",i);
					printf("j: %f \n",j);
					printf("bp: %f \n",BuyPrice[ 
i ]);
					printf("sp: %f \n",SellPrice[ 
j ]);
					printf("spib: %f 
\n",SellPriceAtIndexOfBuy[ i ]);
			}
					
		}
	
	}

}


} 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/Tq9otC/XP.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/