Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, AndrewAMD, Quad), 733 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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