Page 1 of 2

Very basic...but I am stuck

Posted: Tue May 22, 2007 2:28 am
by Blue Rhino
I know this is not TS forum, but I am not getting any help there. I figured why not goto the people that really know how to code stuff anyway. If this is not appropriate then I apologize in advance.

I am mearly trying to enter on a certain date and then place a trailing stop for some backtesting. I was using...

Condition1 = Date = 9/23/2005 ;


if Condition1 then
Buy ( "Entry Name" ) next bar at market;
BUt I was corrected that the Date needed to be Date = 1050923. So, that worked. Now the problem is, I cannot get another date to work like that. I would assume 1050729 would put me in on 07/29/2005, that is not the case. I am also using Percent Stop LX (.2) for a 20% trailing stop. That does not seem to be working. I am looking at the symbol CAT on 9/23/2005 with a 20% trailing stop and it doesn't take me out. I would gladly welcome any and all help that is given to me. Thank you in advance for all your help!

Matt

Posted: Tue May 22, 2007 2:51 am
by TheRumpledOne
Give this a try.

input:

iDate( 1050923);

if date = iDate
then Buy ( "Entry Name" ) next bar at market;


Now you change the input date without recoding the strategy.

Posted: Tue May 22, 2007 2:57 am
by Blue Rhino
TheRumpledOne wrote:Give this a try.

input:

iDate( 1050923);

if date = iDate
then Buy ( "Entry Name" ) next bar at market;


Now you change the input date without recoding the strategy.


Thank you TRO. For some reason it works with that date but no other. Any reason why? I change it from 1050923 to 1050729 and nothing or even 1050924.

Posted: Tue May 22, 2007 3:59 am
by TheRumpledOne
Post your code and workspace, that's the only way I can help you.

Posted: Tue May 22, 2007 11:47 am
by Blue Rhino
input: iDate(1050923);



if Date=idate then
Buy ( "Entry Name" ) next bar at market;

In addition, I am using Percent Stop LX (.2) for a 20% trailing stop. That doesn't seem to be working either. Thanks again!

Posted: Tue May 22, 2007 12:30 pm
by TheRumpledOne
Worked for me:







Are you sure you have the chart data you need?





Code: Select all


[Intrabarordergeneration=true]
 


input: iDate(1050923);


input:


 ShareOrPosition( 1 ), { pass in 1 for per share basis, 2 for position basis }

 ProfitTargetAmt( 0 ), { pass in 0 if you don't want a profit target } 
      
 StopLossAmt( 0 ), { pass in 0 if you don't want a stop loss }
    
 BreakevenFloorAmt( 0 ), { pass in 0 if you don't want a breakeven stop }
 DollarTrailingAmt( 0 ), { pass in 0 if you don't want a dollar trailing stop }
 PctTrailingFloorAmt( 0 ), { pass in 0 here and/or in next input if you don't want
  a percent trailing stop }
 PctTrailingPct( 20 ), { pass in 0 here and/or in previous input if you don't want
  a percent trailing stop; else pass in XX for XX percent }
 ExitOnClose( false) ; { pass in true if you want to exit the position at the
  close of the day, else pass in false. CAUTION: We recommend that you set this to
  TRUE only for back-testing, if at all; in automated execution, the exit order
  will NOT be filled at the close of the day; instead, the order can be sent into
  the extended session as a limit order. }
     
 
{*************************************************}
{    C A L C U L A T I O N S                      }
{*************************************************}

 
if Date=idate then
Buy ( "Entry Name" ) next bar at market;

 

{*************************************************}
{              T A K E   P R O F I T              }
{*************************************************}

if ShareOrPosition = 1
   then  SetStopShare
   else  SetStopPosition ;


if ProfitTargetAmt  > 0 then
 SetProfitTarget( ProfitTargetAmt  ) ;

if StopLossAmt > 0 then
 SetStopLoss( StopLossAmt ) ;

if BreakevenFloorAmt > 0 then
 SetBreakeven( BreakevenFloorAmt ) ;

if DollarTrailingAmt > 0 then
  SetDollarTrailing( DollarTrailingAmt ) ;

if PctTrailingFloorAmt > 0 and PctTrailingPct > 0 then
 SetPercentTrailing( PctTrailingFloorAmt, PctTrailingPct ) ;

if ExitOnClose = true then
 SetExitOnClose ;

Posted: Tue May 22, 2007 1:04 pm
by Blue Rhino
Thank you again. I don't know why on a daily it wasn't working but I can use min charts. Do you know the best trailing stop strategy in TS?

Posted: Tue May 22, 2007 1:38 pm
by TheRumpledOne
I don't think you can run strategies on daily charts, you'll have to ask TS that question.

Trailing Stops DON'T WORK, IMHO. At least, they don't do what you think they do.

Better to exit, when conditions indicate a reversal.

Posted: Tue May 22, 2007 1:42 pm
by Blue Rhino
TheRumpledOne wrote:I don't think you can run strategies on daily charts, you'll have to ask TS that question.

Trailing Stops DON'T WORK, IMHO. At least, they don't do what you think they do.

Better to exit, when conditions indicate a reversal.


I agree, I am just doing some backtesting on some stocks for study though. I thought if I used Percent Trailing (.2) it would trail a 20% stop, that doesn't seem to be happening. Thank you so much for all of your help!

Posted: Tue May 22, 2007 2:50 pm
by TheRumpledOne
20 not .2