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

[amibroker] question about manipulating individual array elements



PureBytes Links

Trading Reference Links

hi,

I finished a simple trading system (for anyone who wants to see it I 
can post it) and now I am trying to make the sell conditions a little 
more complicated. 

Here is the problem:

1) I buy at the open the day AFTER I get a signal

2) I sell with a profit at the threshold level whenever the High 
exceeds the high threshold (which could be on the same day as the 
buy).

3) I sell with a loss at the threshold level whenever the Low exceeds 
the low Threshold (which could be on the same day as the buy).

*** if both low and high thresholds are exceeded on the same day I 
assume the low is exceeded first and therefore I take a loss ***

4) I sell with a profit at the open if the open exceeds the high 
threshold level.

5) I sell with a loss at the open if the open exceeds the low 
threshold level.


below is part of the code:
----------------------------------------------------------------
// overide default settings, set buy delay at 1 bar
SetTradeDelays(1,0,0,0);

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

// high threshold
hit = ValueWhen(Ref(Buy,-1),Open)*1.02;
// low threshold
lot = ValueWhen(Ref(Buy,-1),Open)*0.96;

// setting the buy price at open overides the value in Settings
BuyPrice = Open;

// define the sell conditions
sc1 = H > hit;
sc2 = L < lot;
sc3 = O > hit;
sc4 = O < lot;
sc5 = Cross(BarsSince(Buy), 5 );
----------------------------------------------------------------


OK now the question ........ in some cases both sc1 and sc2 apply. 
This means that I have a 1 at the same index position in the arrays 
sc1 and sc2. Is it possible to replace this "1" at this index 
position inside sc1 and leave it in sc2? In other words can I 
manipulate individual array elements?

thanks in advance,

Ed


------------------------ 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/