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

[amibroker] How to code sequential events ?



PureBytes Links

Trading Reference Links




Tony,See <FONT 
color=#ff0000>embedded.Bob-----Original 
Message-----From: aew_o [<A 
href="">mailto:awenos@xxxxxxxxx]Sent: Monday, 
April 05, 2004 7:32 AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] 
AFL HelpHi All,I've been reviewing some codes to improve my 
programming and findsome things in the following code that I don't 
understand.  I've runthe code and it executes without 
error.#1This line in the procedure:if( box1[j] = swap) I 
would have thought that the operator should have been == to <FONT 
color=#ff0000><== Agreecreate a conditional 
expression.  Why does the code function as isand what is the 
meaning?(there are two occurances like this)  <FONT 
color=#ff0000>No Clue
#2This line in the main loop.if 
(Low[i]<(BoxBot*(1-tick/100)) || High[i]>(BoxTop*(1+tick/100)))The 
conditional operator is ||, but, in the Help file, it shows asa single | can 
be used for an OR operator. What is the proper useageof |?(Again, there are 
multiple ocurrances)
|| is correct- a single | is the bitwise 
or#3This line in the main loop.swap = 
!swap;I have no idea what this might be.As a note, I see 
in the change logs that && and || and ! wereadded as AND/OR/NOT 
synonyms, but in the table of operators theyare shown as & and |. ! is 
not shown as a logical operator. I assumethat the first is correct since the 
code works, but the definitionsin Help are at odds with one another.
All the ops are shown in the 
precedence table [easiest to search in the pdf manual]
! [bang] is the C not operator.
not equal => !=  and [less 
frequently seen] a = !a to invert a boolean.
<FONT 
color=#000000>TIARegardsTony //////////begin/////////box1=0;box2=0;procedure 
fillDarvas(start,end,swap,top, bottom 
){      for ( j = start; j < end; 
j++){       if( box1[j] = 
swap)box1[j]= top ;elsebox1[j]= bottom;if(box2[j] = 
swap)box2[j]= bottom ;elsebox2[j]= top;}}BoxArr1 = 
0;BoxArr2 = 0;StateArray = 0;DBuy = 0;DSell = 0;TopArray = 
0;BotArray = 0;tick=0;BoxTop = High[0];BoxBot = 
Low[0];swap=0;state = 0;BoxStart = 0;for (i=0; 
i<BarCount; i++){if 
(state==5){      TopArray[i]=BoxTop;BotArray[i]=BoxBot;if 
(Low[i]<(BoxBot*(1-tick/100)) || 
High[i]>(BoxTop*(1+tick/100))){fillDarvas(BoxStart,i,swap,BoxTop,BoxBot);state 
= 1;swap = !swap;BoxTop = High[i];BoxStart = 
i;}}else{if (High[i]<BoxTop){if ((state<3) || 
(Low[i]>BoxBot)){state++;       }      else{state=3;}       
       if 
(state==3)BoxBot=Low[i];}else{state=1;BoxTop=High[i];}}StateArray[i] 
= 
state;}fillDarvas(BoxStart,BarCount,swap,BoxTop,BoxBot);Plot(C,"",1,64);Plot( 
box1, "" , colorRed, 512 );Plot( box2, "" , colorGreen , 512 
);///////////end///////////////////Send BUG REPORTS 
to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
suggest@xxxxxxxxxxxxx-----------------------------------------Post 
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx(Web page: 
<A href="" 
target=_blank><FONT 
face=Arial>http://groups.yahoo.com/group/amiquote/messages/<FONT 
face=Arial 
color=#0000ff>)--------------------------------------------Check group 
FAQ at: <A 
href="" 
target=_blank><FONT 
face=Arial>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
face=Arial color=#0000ff>Yahoo! Groups Links<*> To visit your 
group on the web, go to:     <A 
href="" target=_blank><FONT 
face=Arial>http://groups.yahoo.com/group/amibroker/<FONT 
face=Arial color=#0000ff><*> To unsubscribe from this group, send an email 
to:     
amibroker-unsubscribe@xxxxxxxxxxxxxxx<*> Your use of Yahoo! Groups 
is subject to:     <A 
href="" target=_blank><FONT 
face=Arial>http://docs.yahoo.com/info/terms/  



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








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.