Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (AndrewAMD, fairtrader, 3run), 599 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
if (comparison) #420713
04/01/13 14:27
04/01/13 14:27
Joined: Apr 2013
Posts: 2
J
joetrader Offline OP
Guest
joetrader  Offline OP
Guest
J

Joined: Apr 2013
Posts: 2
Zorro is a great program and looking fordward to getting some good results from it when I understand it better.
When the 'if' comparison is true it executes the command but when the 'if' comparison is false it sets the values to "0".
Example:
if(crossOver(Fast,Slow)) BuyStop = 1.4;
Whhen crossOver occurs BuyStop is set to 1.4 as expected. On the next bar when new data arrives and this 'if' evaluates false the BuyStop is changed to 0. I expected it to stay at 1.4 since this 'if' comparison is false. What changed it and how do I keep the BuyStop value at 1.4 until this logic changes it at the next crossOver.

Re: if (comparison) [Re: joetrader] #420729
04/02/13 06:58
04/02/13 06:58
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
In your example, BuyStop just keeps its value when the 'if' condition is not true.

In a programming language, variables do not "change to 0" by themselves. When you define a variable, it gets an initial value. It is normally 0 if you have not defined it otherwise. The variable keeps this value until you explicitly set it to something else. So when you defined your variable just before that 'if' line, it stays 0 of course when the 'if' condition is not true.

Re: if (comparison) [Re: jcl] #420756
04/02/13 16:02
04/02/13 16:02
Joined: Apr 2013
Posts: 2
J
joetrader Offline OP
Guest
joetrader  Offline OP
Guest
J

Joined: Apr 2013
Posts: 2
You put me on the right track. The BuyStop changes to '0' because the variable is reset to '0' every the function is called. I added the word static infront of the var like this:

static var BuyStop;

This fixed the problem of variable resetting to 0. Thanks for the help.

Joe


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1