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

Re: variable



PureBytes Links

Trading Reference Links

> I'm sorry, I think I'm not explaining myself properly and trying
> everyone's patience. 

No, I think you're explaining yourself fine.  You're just confused 
about how it really works.

> Let's say this is my code:

I modified your pseudo-code slightly to make something that's 
actually executable:

Vars: var1(0);
if mod(BarNumber,2) = 0 then var1=var1+1;
print("BarNumber = ",BarNumber:1:0,", var1 = ",var1:2:0);
if var1>=2 then print("var1 >= 2");
if false then plot1(0,"");

I used mod(BarNumber,2)=0 in place of your "condition," and replaced 
your buy;sell;etc code with a print statement.

And here is the output:

 BarNumber = 1, var1 =  0
 BarNumber = 2, var1 =  1
 BarNumber = 3, var1 =  1
 BarNumber = 4, var1 =  2
 var1 >= 2
 BarNumber = 5, var1 =  2
 var1 >= 2
 BarNumber = 6, var1 =  3
 var1 >= 2
 BarNumber = 7, var1 =  3
 var1 >= 2

...etc.  Notice that var1 DOES NOT get reset to 0 on each bar, it 
DOES increase every other bar when the condition is true, and the >=2 
condition happens just like it should.

Isn't that the sort of behavior you're seeing?
Gary