Gamestudio Links
Zorro Links
Newest Posts
Removing outliers from files
by AndrewAMD. 12/02/26 15:26
SGT_FW
by Aku_Aku. 11/30/26 08:19
Experiences with cTrader
by JeyKey II. 11/27/26 09:04
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 6,250 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 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,036
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,036
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,036
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,036
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: 604
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 604
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