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

[amibroker] Better news [was Re: Good news for Ti3() users]



PureBytes Links

Trading Reference Links

Hi All,

I've been reviewing some codes to improve my programming and find
some things in the following code that I don't understand.  I've run
the code and it executes without error.

#1
This line in the procedure:
if( box1[j] = swap)

I would have thought that the operator should have been == to
create a conditional expression.  Why does the code function as is
and what is the meaning?(there are two occurances like this)

#2
This 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 as
a single | can be used for an OR operator. What is the proper useage
of |?(Again, there are multiple ocurrances)

#3
This 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 ! were
added as AND/OR/NOT synonyms, but in the table of operators they
are shown as & and |. ! is not shown as a logical operator. I assume 
that the first is correct since the code works, but the definitions 
in Help are at odds with one another.

TIA

Regards

Tony 

 



 //////////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 ;
else
box1[j]= bottom;

if(box2[j] = swap)
box2[j]= bottom ;
else
box2[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@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:
     http://docs.yahoo.com/info/terms/