Page 1 of 1

TRO TRAILING STOP

Posted: Thu Aug 16, 2007 2:18 am
by TheRumpledOne
TRO TRAILING STOP



Too funny, I just realized today that TradeStation doesn't have a trailing stop INDICATOR. There's the Stops & Targets strategy for auto trading but I don't think there's an indicator. So I wrote one TRO TRAILING STOP to alert you when your stop is hit.

White "+" is the entry price.

Yellow "+" is the stop price.

ELD attached.

Posted: Thu Aug 16, 2007 5:35 pm
by rebkwez
Any chance of being able to write this indicator for eSignal as well.

Thanks.
Elliot

Posted: Thu Aug 16, 2007 9:55 pm
by TheRumpledOne
Not anytime soon.

TS Code

Posted: Tue Aug 21, 2007 8:18 pm
by rebkwez
Avery,

Would you be able to post the TS code so I can convert it to eSignal?

Thanks,
Elliot

Posted: Tue Aug 21, 2007 8:44 pm
by TheRumpledOne

Code: Select all

{ _TRO_TrailingStop  }
   

{Attn: TradeStation
if this indicator is posted on the TradeStation Forum, I, TheRumpledOne, did NOT post it there,
so I can't be blamed for this indicator having my contact info.}


{Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne,
gifts and donations accepted, PO Box 43575, Tucson, AZ 85733 }

{ ? Copyright 2007 Avery T. Horton, Jr.}



Inputs:
 
iDecimals(4),
iStartDate( 1070815),
iStartTime( 1705),
 
iTradeLong(false),
iEntryColor(white),
iStopColor(yellow),
iPrice( 1.9874),
iTrailing( .0007);
 
variables:
 

xStartDate( iStartDate ),
xStartTime( iStartTime ),
xPrice( iPrice ),

xTrail(0),   
xMinPL(0),

   

xPeriods(60),
xInterval(0),

sFirstPass(true),
 
xInd(0),
tInd(""),
tAlert("");

variables:
 
FG1(iStopColor),
BG1(black),

fg2(iEntryColor),
bg2(black),

fg3(white),
bg3(black),

fg4(white),
bg4(black);
   



{commentary variables}
variables:
xcomm(0),
oComm1( "" ),    
oComm2( "" ),    
oComm3( "" ),    
oComm4( "" ),    
oComm5( "" ),
oComm6( "" ),
oComm7( "" ),
oComm8( "" ),
oComm9( "" ),    
oComm10( "" );
   

variables:
xELDateToString(" "),
xDate(0),
xTime(0),         
xOpen(0),   
xClose(0),
xHigh(0),
xLow(0);

   



{ INITIALIZE }

tInd   = "";
tAlert  = "";


{ PROCESSING }
 
If Date = xStartDate
and Time = xStartTime
then begin   

if iTradeLong
   then xTrail = xPrice - iTrailing
    else xTrail = xPrice + iTrailing ;
end;
    

If Date > xStartDate
or ( Date = xStartDate and Time >= xStartTime )
then begin   
   
if iTradeLong
then begin
   value9 = High - iTrailing ;
   If value9 > xTrail
      then xTrail = value9 ;
   if close <= xTrail
      then tAlert  = "Long Stop Hit";
end;


if iTradeLong = false
then begin
   value9 = Low + iTrailing ;
   If value9 < xTrail
      then xTrail = value9 ;
   if close >= xTrail
      then tAlert  = "Short Stop Hit";
end;
    

{ Alert }

if tAlert <> ""
and tAlert <> tAlert[1]
   then Alert( tAlert ) ;


{ PLOT }



Plot1( xTrail , "Stop Price", fg1 ) ;
SetPlotBGColor( 1, bg1);

Plot2( xPrice , "Entry Price", fg2 ) ;
SetPlotBGColor( 2, bg2);
end ;



xComm = _fCommentary(oComm1, oComm2, oComm3, oComm4, oComm5, oComm6, oComm7, oComm8, oComm9, oComm10);

CommentaryCl(oComm1 );

CommentaryCl(oComm2 );
CommentaryCl(oComm3 );
CommentaryCl(oComm4 );
CommentaryCl(oComm5 );
CommentaryCl(oComm6 );
CommentaryCl(oComm7 );
CommentaryCl(oComm8 );
CommentaryCl(oComm9 );
CommentaryCl(oComm10 );

CommentaryCl( " " );


CommentaryCl( "xPrice: ", NumToStr( xPrice , iDecimals) );


CommentaryCl( "xTrail: ", NumToStr( xTrail , iDecimals) );

xELDateToString = ELDateToString(xStartDate);

CommentaryCl( "xStartDate: ",  xELDateToString  );

Re: TS /Esig Code

Posted: Wed Aug 22, 2007 2:25 am
by zeller4
rebkwez wrote:Avery,

Would you be able to post the TS code so I can convert it to eSignal?

Thanks,
Elliot


Elliot,

please post the .efs when you're done.

Thanks,
Kirk