Very basic...but I am stuck

If you don't know where to start, start here! Don't be afraid to ask questions.

Moderator: moderators

User avatar
Blue Rhino
rank: <50 posts
rank: <50 posts
Posts: 16
Joined: Wed May 09, 2007 1:04 pm
Reputation: 0
Location: Atlanta
Gender: Male

Very basic...but I am stuck

Postby Blue Rhino » Tue May 22, 2007 2:28 am

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

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Tue May 22, 2007 2:51 am

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.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!

Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
Blue Rhino
rank: <50 posts
rank: <50 posts
Posts: 16
Joined: Wed May 09, 2007 1:04 pm
Reputation: 0
Location: Atlanta
Gender: Male

Postby Blue Rhino » Tue May 22, 2007 2:57 am

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.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Tue May 22, 2007 3:59 am

Post your code and workspace, that's the only way I can help you.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
Blue Rhino
rank: <50 posts
rank: <50 posts
Posts: 16
Joined: Wed May 09, 2007 1:04 pm
Reputation: 0
Location: Atlanta
Gender: Male

Postby Blue Rhino » Tue May 22, 2007 11:47 am

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!
Attachments
CAT.jpg
CAT.jpg (61.62 KiB) Viewed 6279 times

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Tue May 22, 2007 12:30 pm

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 ;
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
Blue Rhino
rank: <50 posts
rank: <50 posts
Posts: 16
Joined: Wed May 09, 2007 1:04 pm
Reputation: 0
Location: Atlanta
Gender: Male

Postby Blue Rhino » Tue May 22, 2007 1:04 pm

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?

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Tue May 22, 2007 1:38 pm

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.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
Blue Rhino
rank: <50 posts
rank: <50 posts
Posts: 16
Joined: Wed May 09, 2007 1:04 pm
Reputation: 0
Location: Atlanta
Gender: Male

Postby Blue Rhino » Tue May 22, 2007 1:42 pm

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!

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Tue May 22, 2007 2:50 pm

20 not .2
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “beginners forum”