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

coding a stop



PureBytes Links

Trading Reference Links

Hi Phil,
I hope I have figured out what you are trying to do. It is quite simple.
To recap, the following TS code will do as follows:-
* Determine if you are long
*  If the close > the open by a fixed amount then run the stop
* The long exit stop is to get out at Low-0.1
* Your problem is that your stop works only on the first bar and then it 
becomes invalid. To solve this, you need a "switch" that stays on until you 
are stopped out.

Phil, you definition of "0.1" is as muddy as a blues vinyl LP. Phil, what I 
have done is set the "0.1" as an input so that you can change it if you want:

Inputs:FixedAmount(2),Muddy(0.1);

Var:Switch(0);

{Determine that you are long}
If Marketposition=1 then begin
{Determine if C-O>"Fixed Amount")
If (Close-Open)>FixedAmount then Switch=1;
end;

{Set the below stop only if the switch is set to 1}
If Switch=1 then begin
ExitLong at Low-Muddy Stop;
end;

{Reset switch back to zero when you have no position in the market}
If Marketposition=0 then Switch=0;

HTH,

Best Regards,

Robert Bianchi
r.bianchi@xxxxxxxxx


 >Date: Thu, 10 May 2001 20:46:54 +0200
 >From: Philip Arnstein <shraga@xxxxxxxxxxxx>
 >To: "omega-list@xxxxxxxxxx" <omega-list@xxxxxxxxxx>
 >Subject: coding a stop
 >Message-ID: <3AFAE21E.B18D3870@xxxxxxxxxxxx>
 >Content-Type: text/plain; charset=us-ascii
 >Content-Transfer-Encoding: 7bit
 >MIME-Version: 1.0
 >Hi all,
 >I`m trying to create a stop where if I`m long, and this bar`s close is >
 >"amount" than open (meaning it`s an up bar) then a stop should be placed
 >0.1 under the low. The problem is, that it on works for the next bar,
 >but if the next bar is not > "amount" (and therefore the stop will not
 >move to under its low) and then the NEXT bar will go lower than the low
 >of two bars ago - 0.1, the stop won`t work...
 >Here`s the code so far:
 >var: stoppl(0);
 >input: num(2);
 >stoppl=low of this bar-0.1;
 >if close-open > num then exitlong at stoppl stop;
 >Any help would be greatly appreciated!
 >Philip