[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: How to code initial stop loss?



PureBytes Links

Trading Reference Links

Hello Benjamin,

Thanks a lot for your help, it's exactly what I want. :)

Wednesday, September 4, 2002, 9:20:16 PM, you wrote:

BB> Here is a sample of the EasyLanguage you could use to create the initial
BB> stop loss using market, stop and limit orders in TS4 or TS2ki.  In TS6 you
BB> will need to use Buy to enter a long position, Sell to exit a long position,
BB> SellShort to enter a short position and BuyToCover to exit a short position.

BB> { *** begin *** }
BB> Inputs: nBarsAgo( 0 ) ;
BB> Variables: MP( 0 ), InitialLngStpVal( 0 ), InitialShtStpVal( 0 ) ;

BB> MP = MarketPosition ;

BB> If MP = 1 and MP[ 1 ] < 1 then
BB>   InitialLngStpVal = Lowest( Low, nBarsAgo ) ;
BB> If MP = 1 then
BB>   ExitLong next bar at InitialLngStpVal stop ;

BB> If MP = -1 and MP[ 1 ] > -1 then
BB>   InitialShtStpVal = Highest( High, nBarsAgo ) ;
BB> If MP = -1 then
BB>   ExitShort next bar at InitialShtStpVal stop ;
BB> { *** end *** }

BB> If you are using close orders then you will need to manually update the
BB> variable MP directly in the signal as you place the order.  For example:

BB> { *** begin *** }
BB> Inputs: nBarsAgo( 0 ) ;
BB> Variables: MP( 0 ), InitialLngStpVal( 0 ), InitialShtStpVal( 0 ) ;

BB> MP = MarketPosition ;

BB> If Condition1 then begin
BB>   MP = 1 ;
BB>   Buy this bar on Close ;
BB> End ;

BB> If Condition2 then begin
BB>   MP = -1 ;
BB>   Sell this bar on Close ;
BB> End ;

BB> If MP = 1 and MP[ 1 ] < 1 then
BB>   InitialLngStpVal = Lowest( Low, nBarsAgo ) ;
BB> If MP = 1 then
BB>   ExitLong next bar at InitialLngStpVal stop ;

BB> If MP = -1 and MP[ 1 ] > -1 then
BB>   InitialShtStpVal = Highest( High, nBarsAgo ) ;
BB> If MP = -1 then
BB>   ExitShort next bar at InitialShtStpVal stop ;
BB> { *** end *** }


BB> Best regards,

BB> Benjamin Blanco,
BB> EasyLanguageŽ Specialist
BB> ( former TradeStation Technologies, Inc. employee of six years )
BB> http://www.blancofamily.net/ezlang.htm

BB> EasyLanguage is a registered trademarks of TradeStation Technologies, Inc.

BB> ----- Original Message -----
BB> From: "AceTrader" <tradersh@xxxxxxxxxxxx>
BB> To: <omega-list@xxxxxxxxxx>
BB> Sent: Wednesday, September 04, 2002 8:50 AM
BB> Subject: How to code initial stop loss?


BB> I wanted to code the initial stop loss base on the lowest low/highest
BB> high of N bar ago at the time of long/short entry. Can anyone help?
BB> Thanks in advance.



BB> --
BB> Best regards,
BB>  AceTrader                          mailto:tradersh@xxxxxxxxxxxx







-- 
Best regards,
 AceTrader                            mailto:tradersh@xxxxxxxxxxxx