------ Compiled with error(s): ------
syntax error, unexpected 'identificator', expecting 'string constant'
errLine 44, errColumn 9, errLineEnd 44, errColumnEnd 9
causal study: (Function)
when I compile the code below...please advice. Thanks
Code: Select all
inputs:
ProfitTgt1( 1.5 ), // all % inputs are integers, where 1 = 1%
ProfitTgt2( 3.0 ),
ProfitTgt3( 4.0 ),
Tgt1PcntExit( 33.333 ),
Tgt2PcntExit( 33.333 ),
Tgt3PcntExit( 50 ),
StopLossTgt( 1.0 ),
NumShares( 600 ) ;
variables:
MP( 0 ),
StopLossPrice( 0 ),
Exit3Bar( 0 ),
Exit1( false ),
Exit2( false ) ;
// Get the current market position: -1 = Short; 0 = Flat ; 1 = Long
MP = MarketPosition ;
// Create dummy entries to test scaling out exits. Enter on first bar or 5 bars after
// last exit.
//if CurrentBar = 1 or ( TotalTrades > 0 and BarsSinceExit(1) >= 5 ) then
//Buy NumShares shares at next bar at market ;
// If the enter price > 0 then we are in a position.
if EntryPrice > 0 then
begin
// If the stop loss price is zero then set it to the initial stoploss target below
// the entry price
if StopLossPrice = 0 then
StopLossPrice = EntryPrice * ( 1 - ( StopLossTgt / 100 ) ) ;
// If the first profit target exit has not yet occurred and the current bar high
// is greater than or equal to the first profit target, then exit a percentage of
// the Initial position. Adjust the stop loss price to break even - the entry price.
if Exit1 = false and High >= EntryPrice * ( 1 + ( ProfitTgt1 / 100 ) ) then
begin
Exit1 = true ;
Sell ( Tgt1PcntExit /100 ) * NumShares Shares Total at next bar at market ;
StopLossPrice = EntryPrice ;
end
// If the second profit target exit has not yet occurred and the current bar high
// is greater than or equal to the second profit target, then exit a percentage of
// the initial position. Adjust the stop loss price to the current bar close.
else if Exit2 = false and High >= EntryPrice * ( 1 + ( ProfitTgt2 / 100 ) ) then
begin
Exit2 = true ;
Sell ( Tgt2PcntExit / 100 ) * NumShares Shares Total at next bar at market ;
StopLossPrice = Close ;
end
// If the third profit target exit has not yet occurred and the current bar high
// is greater than or equal to the third profit target, then exit a percentage of
// the CURRENT (not Initial) position.
else if Exit3Bar = 0 and High >= EntryPrice * ( 1 + ( ProfitTgt3 / 100 ) ) then
begin
Sell ( Tgt3PcntExit / 100 ) * CurrentShares Shares Total at next bar at market ;
Exit3Bar = CurrentBar + 3 ;
end ;
// Dummy exit to exit remaining shares 3 bars after third profit target hit so that we
// can enter again to test the scaled out exits.
if Exit3Bar = CurrentBar then
Sell at next bar at market ;
end ;
// If the market position of the prior bar is not zero (in a position) and the current market position
// is zero then we have just exited a trade - reset all the exit variables and stop loss price for
// the next entry and exits.
if MP[1] <> 0 and MP = 0 then
begin
Exit1 = false ;
Exit2 = false ;
Exit3Bar = 0 ;
StopLossPrice = 0 ;
end ;