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);