Trendline Strategy not compiling  [SOLVED]

Questions about MultiCharts and user contributed studies.
designer01
Posts: 80
Joined: 02 Feb 2010

Trendline Strategy not compiling

Postby designer01 » 26 Jun 2013

I have this manual drawn Trendline StopLoss strategy but for some reason it's not compiling. Not sure why ...it may be the shares name? Please advice. Thanks in advance...
I get this error...

Study: "StopLoss" (Signal)
Please wait ....
------ Compiled with error(s): ------
syntax error, unexpected 'share'
errLine 16, errColumn 32, errLineEnd 16, errColumnEnd 32
causal study: (Function)

Code: Select all

input:
TLColor( YELLOW ),
AllMarketOrders ( FALSE ), {TRUE = Creates Conditional Market orders when the Profit Target is true on the bar close }
CreateTestEntry ( FALSE ), {TRUE = Creates a test position to exit for a real world discretionary position}
SharesLongShort ( 500 ); {Positive shares(500) = Buy Entry, Negative shares(-500) = Sell Short Entry}

variables:
CurrentTLValue( 0 ),
TextStr("");

if currentbar = 1 and CreateTestEntry then begin
if SharesLongShort >= 1 then
Buy next bar SharesLongShort Shares at Market;
if SharesLongShort <= -1 then
Sell Short next bar -SharesLongShort Shares at Market;
end;

CurrentTLValue = -1;

if LastBarOnChart AND Marketposition <> 0 then begin

if Marketposition = 1 then begin
TextStr = "LX - No Stop Order Generated";
if Value99 = 0 then
Value99 = Text_New( D, T, 0, TextStr);
end;

if MarketPosition = -1 then begin
TextStr = "SX - No Stop Order Generated";
if Value99 = 0 then
Value99 = Text_New( D, T, 0, TextStr);
end;

if Value1 <= 0 then
Value1 = TL_FindColor( 3, TLColor );

if Value1 > -1 then
CurrentTLValue = TL_GetValue( Value1, D, T );

if CurrentTLValue > 0 then begin

if CurrentTLValue <> CurrentTLValue[1] AND Value99 > 0 then begin
Text_SetString(Value99," ");
Text_SetLocation( Value99, D, T, 0 );
end;

if MarketPosition = 1 AND CurrentTLValue <= Close then begin
if AllMarketOrders then begin
if Close <= CurrentTLValue then
Sell ( "TLSellStopLX" ) next bar at Market;
TextStr = "LX Sell Stop "+numtoStr(CurrentContracts,0)+" at "+numtoStr(CurrentTLValue,2)+" cMarket -->";
end
else begin
Sell ( "TLSellStop LX" ) next bar at CurrentTLValue Stop;
TextStr = "LX Sell Stop "+numtoStr(CurrentContracts,0)+" at "+numtoStr(CurrentTLValue,2)+" Market -->";
end;
end;

if MarketPosition = -1 AND CurrentTLValue >= Close then begin
if AllMarketOrders then begin
if Close >= CurrentTLValue then
Buy To Cover ( "TLSellStopSX" ) next bar at Market;
TextStr = "SX Buy To Cover Stop "+numtoStr(-CurrentContracts,0)+" at "+numtoStr(CurrentTLValue,2)+" cMarket -->";
end
else begin
Buy To Cover ( "TLSellStop SX" ) next bar at CurrentTLValue Stop;
TextStr = "SX Buy To Cover Stop "+numtoStr(-CurrentContracts,0)+" at "+numtoStr(CurrentTLValue,2)+" Market -->";
end;
end;

Text_SetString(Value99, TextStr);
Text_SetLocation(Value99, D, T, CurrentTLValue );
Text_SetStyle( Value99, 1,1);
Text_SetColor( Value99, TLColor);

end;

END;

if atcommentarybar then
Commentary("Reset Strategy 'TL Stop Loss' = OK"+NEWLINE);

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Trendline Strategy not compiling  [SOLVED]

Postby sptrader » 26 Jun 2013

It's not the word "shares" it's the order sequence- I just re-arranged the sequence and it compiles...this part does anyway)

Code: Select all

if currentbar = 1 and CreateTestEntry then begin
if SharesLongShort >= 1 then
Buy SharesLongShort shares next bar at Market;
if SharesLongShort <= -1 then
SellShort -SharesLongShort Shares next bar at Market;
end;

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Trendline Strategy not compiling

Postby designer01 » 26 Jun 2013

sptrader, Thank you seems to work fine


Return to “MultiCharts”