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

Re: Using the H/L of entry bar as a stop?



PureBytes Links

Trading Reference Links

If I understand your question correctly you are trying to save the low
and/or the high of the entry bar to establish a point to set your stop
loss from.

That can be done with something like this:

Var:barlow(0),barhigh(0);

if A = B then begin (your conditions for a long or short entry)
	barlow = low;
	barhigh = high;
	buy this bar at close; (or sell this bar at close)
	end;
if MarketPosition <> 0 and BarsSinceEntry >= 1 then begin
	(your stop loss conditions)
	end;
OR
if MarketPosition =1 and BarsSinceEntry >= 1 then begin
	(your long stop loss conditions)
	end;
if MarketPosition =-1 and BarsSinceEntry >= 1 then begin
	(your short stop loss conditions)
	end;

Barlow or barhigh can be compared to whatever you are using for current
price to determined if the current price has fallen below the low of the
entry bar or above the high of the entry bar.

Also - TS does save the "entryprice" of the trade as a reserved word. TS
considers this price to be the close of the bar.

BTW - It is not necessary to initialize the variable mp to 0 as you did
in your code example - the variable is already set to zero by the
statement - Var:mp(0);

The first thing that TS does is read the var statements and set the
variables accordingly.  This is a one time look by TS.

Larry

"Thomas J. Festa" wrote:
> 
> I would like to insert this code into another signal for TS2000i.
> 
> How do I do the following?:
> 
> << { low = low of bar of entry, save as a variable }: >>
> 
> -- And set a StopLoss there?
> 
> Thomas
> 
> ==========================================
> Variable:       mp(0);  { marketPosition }
> 
> { initialize variable }
> if currentBar = 1 then begin
>    mp = 0;
> end;
> 
> { assign value to variable }
> mp = marketPosition;
> 
> { determines trade entry }
> if mp<> 0 and barsSinceEntry = 0 then begin
>    if mp = +1 then
>       { you're long } ... { low = low of bar of entry, save as a variable }
>    else if mp = -1 then
>       { you're short };
> end;
> { determines trade exit }
> { allows for multiple exits on the same bar }
> for value1 = 2 downTo 1 begin
>    if barsSinceExit(value1) = 0 then begin
>       if marketPosition(value1) = +1 then
>          { you exited a long position }
>       else if marketPosition(value1) = -1 then
>          { you exited a short position };
>    end;
> end;
> 
> { for systems that trade on the close }
> if mp<> 0 and barsSinceEntry = 1 then begin ...
>    { low[1] = low of bar of entry, save as a variable }
> 
> =========================================================================
> 
> Thomas J. Festa, CMT
> Technical Analysis Investment Consultant
> Proprietary Trader, Equities
> Benchmarq Trading, LLC  10003
> Cell:   (908) 581-8880
> 
> Confidentiality Notice: The information contained in this e-mail and any
> attachments may be legally privileged and confidential. If you are not an
> intended recipient, you are hereby notified that any dissemination,
> distribution, or copying of this e-mail is strictly prohibited. If you have
> received this e-mail in error, please notify the sender and permanently
> delete the e-mail and any attachments immediately. You should not retain,
> copy or use this e-mail or any attachment for any purpose, nor disclose all
> or any part of the contents to any other person.