TS - 2000i Code not being compiled in MC  [SOLVED]

Questions about MultiCharts and user contributed studies.
JitinC
Posts: 5
Joined: 15 Dec 2012
Has thanked: 2 times

TS - 2000i Code not being compiled in MC

Postby JitinC » 22 Dec 2012

Below is a TS-2000i Code with is not being compiled on MC, Please advice:

Code: Select all

{Sys - 5 Ch Breakout}
   
{5 Bar Channel breakout with a 45 bar MA trend filter.
 Applied on a 60 min intrady Nifty Future.}

inputs: hibar(5), lowbar(5), MovAvg(45), exitbar(18), Tradeunits(8);
vars: ma(0);

{calculate the 45 bar moving average}
ma = Average(close, MovAvg);

{The buy and sell conditions with Moving Average Filter}
if close > ma then buy Tradeunits contracts at highest(high, hibar) stop;

if close < ma then sell Tradeunits contracts at lowest(low, lowbar) stop;

{The Exit conditions}

if marketposition = 1 then exitlong at lowest(low, exitbar) stop;
if marketposition = -1 then exitshort at highest(high, exitbar) stop;

if lastbaronchart then exitlong;
if lastbaronchart then exitshort;

User avatar
TJ
Posts: 6571
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1899 times

Re: TS - 2000i Code not being compiled in MC

Postby TJ » 22 Dec 2012

JitinC wrote:Below is a TS-2000i Code with is not being compiled on MC, Please advice:
{Sys - 5 Ch Breakout}
{5 Bar Channel breakout with a 45 bar MA trend filter.
Applied on a 60 min intrady Nifty Future.}
inputs: hibar(5), lowbar(5), MovAvg(45), exitbar(18), Tradeunits(8);
vars: ma(0);
{calculate the 45 bar moving average}
ma = Average(close, MovAvg);
{The buy and sell conditions with Moving Average Filter}
if close > ma then buy Tradeunits contracts at highest(high, hibar) stop;
if close < ma then sell Tradeunits contracts at lowest(low, lowbar) stop;
{The Exit conditions}
if marketposition = 1 then exitlong at lowest(low, exitbar) stop;
if marketposition = -1 then exitshort at highest(high, exitbar) stop;
if lastbaronchart then exitlong;
if lastbaronchart then exitshort;

You have to post the error message.


ps. please use code tag when posting codes, it makes reading codes easier.
To tag the codes, simply highlight the codes you are about to post, then click the "Code" button located at the top of the message window.

ps. I have tagged them for you in your post.

JitinC
Posts: 5
Joined: 15 Dec 2012
Has thanked: 2 times

Re: TS - 2000i Code not being compiled in MC

Postby JitinC » 22 Dec 2012

Error Message:

22.12.12 23:12:08
------ Build started: ------
Study: "Sys 5 CBO N60" (Signal)
Please wait ....
------ Compiled with error(s): ------
syntax error, unexpected 'identificator'
errLine 26, errColumn 39, errLineEnd 26, errColumnEnd 39
causal study: (Function)

User avatar
TJ
Posts: 6571
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1899 times

Re: TS - 2000i Code not being compiled in MC

Postby TJ » 22 Dec 2012

JitinC wrote:Error Message:

22.12.12 23:12:08
------ Build started: ------
Study: "Sys 5 CBO N60" (Signal)
Please wait ....
------ Compiled with error(s): ------
syntax error, unexpected 'identificator'
errLine 26, errColumn 39, errLineEnd 26, errColumnEnd 39
causal study: (Function)

What does that tell you?

sptrader
Posts: 633
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 394 times
Been thanked: 236 times
Contact:

Re: TS - 2000i Code not being compiled in MC

Postby sptrader » 22 Dec 2012

I made the changes to reflect the syntax difference of MC...
If you have the .els or .ela when you import the file MC usually makes the required changes for you.. untested but it does verify and give signals-

Code: Select all

{Sys - 5 Ch Breakout}
   
{5 Bar Channel breakout with a 45 bar MA trend filter.
Applied on a 60 min intrady Nifty Future.}

inputs: hibar(5), lowbar(5), MovAvg(45), exitbar(18), Tradeunits(8);
vars: ma(0);

{calculate the 45 bar moving average}
ma = Average(close, MovAvg);

{The buy and sell conditions with Moving Average Filter}
if close > ma then buy Tradeunits contracts next bar at highest(high, hibar) stop;

if close < ma then sellshort Tradeunits contracts next bar at lowest(low, lowbar) stop;

{The Exit conditions}

if marketposition = 1 then sell next bar at lowest(low,exitbar) stop;
if marketposition = -1 then buytocover next bar at highest(high, exitbar) stop;

if lastbaronchart then sell next bar at market;
if lastbaronchart then buytocover next bar at market;
Last edited by sptrader on 22 Dec 2012, edited 1 time in total.
These users thanked the author sptrader for the post:
JitinC

JitinC
Posts: 5
Joined: 15 Dec 2012
Has thanked: 2 times

Re: TS - 2000i Code not being compiled in MC

Postby JitinC » 22 Dec 2012

Thanks a ton!

It seems that its a problem with code compatibility.

JitinC
Posts: 5
Joined: 15 Dec 2012
Has thanked: 2 times

Re: TS - 2000i Code not being compiled in MC

Postby JitinC » 22 Dec 2012

Problem:

When i run this code, the system only takes Long trade, it does not take any Short trade.

Please advice.

Thanks

User avatar
ABC
Posts: 520
Joined: 16 Dec 2006
Has thanked: 111 times
Been thanked: 295 times
Contact:

Re: TS - 2000i Code not being compiled in MC  [SOLVED]

Postby ABC » 22 Dec 2012

Change this line:

Code: Select all

if close < ma then sell Tradeunits contracts next bar at lowest(low, lowbar) stop;


to this:

Code: Select all

if close < ma then sellshort Tradeunits contracts next bar at lowest(low, lowbar) stop;


In TS2000i sell was the reserved word to execute a short, now it's used to exit a long position.

Regards,

ABC
These users thanked the author ABC for the post (total 3):
sptraderTJJitinC


Return to “MultiCharts”