Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
syntax error - help please #475150
11/26/18 08:45
11/26/18 08:45
Joined: Apr 2018
Posts: 46
M
MINER Offline OP
Newbie
MINER  Offline OP
Newbie
M

Joined: Apr 2018
Posts: 46
I HAVE THE FOLLOWING PIECE OF CODE BUT WHEN I TRY TO RUN IT, THERE IS SYNTAX ERROR AT THIS LINE
"vars Close = series(priceClose()); "
KINDLY HELP ME PUT THIS IN A FUNCTIONAL WAY, .....AND MAYBE ADD ANY OTHER USEFUL INFORMATION I MAY BE REQUIRED TO ADD TO THE SCRIPT. THANK YOU wink wink


//TMF to adjust the stop in a special way for Long
int TrailingStopLong()
{
//adjust the stop only when the trade is in profit
if(TradeProfit > 0)
//place the stop at te lowest bottom of the previous 3 candles
TradeStopLimit = max(TradeStopLimit,LL(3));
//plot a line to make the stop limit visible
plot("stop", TradeStopLimit, MINV, BLACK);
//RETURN 0 FOR CHECKING THE LIMITS
return 0;
}

int TrailingStopShort()
{
//adjust the stop only when the trade is in profit
if(TradeProfit > 0)
//place the stop at the highest top of the previous 3 candles
TradeStopLimit = max(TradeStopLimit,HH(3));
//plot a line to make the stop limit visible
plot("stop", TradeStopLimit, MINV, BLACK);
//RETURN 0 FOR CHECKING THE LIMITS
return 0;
}
//Trade when a fast SMA crosses over a slow SMA

function run()
{


StartDate = 2005;
BarPeriod = 60;
Lots = 30;
MaxLong = 1;
MaxShort = 1;
//Stop = 2 * ATR(14);
//Trail = 2 * ATR(14);
//EntryTime =
Entry = -5*PIP;
Algo = "SMA 15,5"

vars Close = series(priceClose());
vars SMAFast = series(SMA(Close, 5));
vars SMASlow = series(SMA(Close, 15));

if(crossOver(SMAFast, SMASlow))
enterLong(TrailingStopLong);
else if(crossUnder(SMAFast, SMASlow))
exitLong(TrailingStopShort);
//exit long and go short if 5 SMA crosses under 15 SMA
if(crossUnder(SMAFast, SMASlow))
enterShort();
else if(crossOver(SMAFast, SMASlow))
exitShort();


for(open_trades)
if(TradeIsOpen && !TradeIsPool && TradeProfit > 0) {
TradeTrailLock = 0.80; // 80% profit (minus trade costs)
if(TradeIsShort)
TradeTrailLimit = max(TradeTrailLimit,TradePriceClose);
else
TradeTrailLimit = min(TradeTrailLimit,TradePriceClose);
}


//plot the graph

set(PLOTNOW);
PlotWidth = 1200;
PlotHeight1 = 400;
}

Re: syntax error - help please [Re: MINER] #475154
11/26/18 10:39
11/26/18 10:39
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
From the manual:

"Error messages when compiling the script indicate simple syntax errors. Something is mistyped, or a bracket or semicolon is missing..."

Re: syntax error - help please [Re: jcl] #475245
11/29/18 11:03
11/29/18 11:03
Joined: May 2018
Posts: 8
A
Adey Offline
Newbie
Adey  Offline
Newbie
A

Joined: May 2018
Posts: 8
Hi

When you get these errors, they are sometimes in the line before the reported error.

Look at the line before the error. Missing a semi colon.

Re: syntax error - help please [Re: Adey] #475248
11/29/18 12:35
11/29/18 12:35
Joined: Apr 2018
Posts: 46
M
MINER Offline OP
Newbie
MINER  Offline OP
Newbie
M

Joined: Apr 2018
Posts: 46
Thank you jcl && Adey.....figured out the error


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1