Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,528 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Newbie Syntax Error #408294
09/28/12 20:27
09/28/12 20:27
Joined: Sep 2012
Posts: 14
Tracy, CA
J
jlittle984 Offline OP
Newbie
jlittle984  Offline OP
Newbie
J

Joined: Sep 2012
Posts: 14
Tracy, CA
OK,

Just trying to write a basic script that goes long when price closes above 13 period EMA and goes short when price closes below 13 period EMA. Not much to it, but I'm getting a syntax error when I test it.

For the life of me, I cannot get this very simple script to compile. It's giving me a syntax error at the enterLong function.

Please have patience and mercy - I am a total newb with scripting at this level. I'm hoping someone can lay eyes on this and say "you missed "insert snarky comment here", idiot!"). It seems to work fine if I comment out beginning at the "else if...portion".

function run()
{
var *Price = series(priceClose());
var *Trend = series(EMA(Price,13));


if(Price<Trend)
enterShort();
Stop = 2*ATR(100);
Profit=100*PIP;

else if(Price>Trend)
enterLong();
Stop = 2*ATR(100);
Profit=100*PIP;
}

Thanks in advance!

Re: Newbie Syntax Error [Re: jlittle984] #408296
09/28/12 21:08
09/28/12 21:08
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
If i were you i would try this, instead of that code.
Code:
function run()
{
var *Price = series(priceClose());
var *Trend = series(EMA(Price,13));


if(Price<Trend) {
enterShort();
Stop = 2*ATR(100);
Profit=100*PIP;
}
else
 if(Price>Trend) {
enterLong();
Stop = 2*ATR(100);
Profit=100*PIP;
}
}


Maybie...

Last edited by Aku_Aku; 09/28/12 21:14.
Re: Newbie Syntax Error [Re: Aku_Aku] #408298
09/28/12 22:04
09/28/12 22:04
Joined: Sep 2012
Posts: 14
Tracy, CA
J
jlittle984 Offline OP
Newbie
jlittle984  Offline OP
Newbie
J

Joined: Sep 2012
Posts: 14
Tracy, CA
Cool thanks for the advice. It's weird because the if/else statements in the tutorials aren't bracketed that way, but the script compiled and ran. Couple of errors I need to dig into, but at least the syntax error is gone.

Thanks for taking the time to post. Much appreciated.

Re: Newbie Syntax Error [Re: jlittle984] #408299
09/28/12 22:29
09/28/12 22:29
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Hmmm... Could you show here that script?

Re: Newbie Syntax Error [Re: Aku_Aku] #408318
09/29/12 11:58
09/29/12 11:58
Joined: Apr 2008
Posts: 594
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 594
Austria
You need brackets when the if() controls more than 1 command, and I think you also have the order wrong. The trade needs Stop and Profit, so you must set them first and then enter the trade.


Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1