Problem about a strategy's code I cannot solve

Questions about MultiCharts and user contributed studies.
paolox075
Posts: 1
Joined: 26 Sep 2014

Problem about a strategy's code I cannot solve

Postby paolox075 » 16 Oct 2014

Good mornin. Is there someone who will read this post which is able to solve a problem with this code:

Inputs: HighValue(High), LowValue(Low), CloseValue(Close),Price(Close),Lenght(14),Strenght(75),Weaken(25);


If FastKCustom(HighValue, LowValue, CloseValue, Lenght ) crosses under
FastDCustom(HighValue, LowValue, CloseValue, Lenght) and FastDCustom(HighValue,
LowValue, CloseValue, Lenght) >= Strenght then Buy next bar at market;

If FastKCustom(HighValue, LowValue, CloseValue, Lenght ) crosses over
FastDCustom(HighValue, LowValue, CloseValue, Lenght) and FastDCustom(HighValue,
LowValue, CloseValue, Lenght) <= Weaken Then Sellshort next bar at market;



If MarketPosition = 1 Then Begin
Sell currentcontracts/2 at EntryPrice + averagetruerange(lenght) Limit;
Sell at Low[2] - .3 * averagetruerange(Lenght) Stop;
End;

If MarketPosition = -1 then Begin
BuytoCover currentcontracts/2 at EntryPrice - averagetruerange(Lenght) Limit;
Sell at High[2] + .3 * averagetruerange(Lenght) stop;
End;

All seems right bu when I compile powerLanguage returns me : Syntax error expecting 'bars'
Line0 Column 0
Thank you in advance

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Problem about a strategy's code I cannot solve

Postby TJ » 16 Oct 2014

ps.
[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: Problem about a strategy's code I cannot solve

Postby evdl » 16 Oct 2014

Edit your code somewhat

Code: Select all

Inputs:
HighValue(High),
LowValue(Low),
CloseValue(Close),
Price(Close),
Lenght(14),
Strenght(75),
Weaken(25);

Vars:
NumberOfContracts(0);


If FastKCustom(HighValue, LowValue, CloseValue,Lenght)
crosses under
FastDCustom(HighValue, LowValue, CloseValue,Lenght)

and

FastDCustom(HighValue, LowValue,CloseValue, Lenght) >= Strenght
then Buy next bar at market;


If FastKCustom(HighValue, LowValue, CloseValue, Lenght)
crosses over
FastDCustom(HighValue, LowValue, CloseValue, Lenght)

and

FastDCustom(HighValue, LowValue,CloseValue, Lenght) <= Weaken
Then Sellshort next bar at market;

NumberOfContracts = Currentcontracts * 0.5;

If MarketPosition = 1 Then Begin
Sell NumberOfContracts contracts next bar at (EntryPrice + averagetruerange(lenght) ) Limit;
Sell NumberOfContracts contracts next bar at (Low[2] - (0.3 * averagetruerange(Lenght)) ) Stop;
End;

If MarketPosition = -1 then Begin
BuytoCover NumberOfContracts contracts next bar at (EntryPrice - averagetruerange(Lenght)) Limit;
BuyToCover NumberOfContracts contracts next bar at (High[2] + (0.3 * averagetruerange(Lenght)) ) stop;
End;


Return to “MultiCharts”