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

re: Problem with Code for Exiting on day of Entry



PureBytes Links

Trading Reference Links

 Adrian,

 Here is some code that exits on entry bar at a predetermined profit or
loss.    Code is for TS6.

 Regards,

 Barry Silberman


 ======================================================================

 inputs:  NoContracts(2), Profitpoints_1(1), stpLossPts(2);
Var:     opn(0),   EB_profit_lg(0),  EB_profit_Short(0), stoploss(0),
EB_loss_lg(0),  EB_loss_Short(0);


 {determine entrybar exits}
 opn = (open)data1  of tomorrow;

 {entrybar exits for profits}
 EB_profit_lg = opn + profitpoints_1;
 EB_profit_Short = opn - profitpoints_1;

 {entrybar exits for losses}
 stoploss = stpLossPts;

 EB_loss_lg = opn - Stoploss;
EB_loss_Short = opn + stoploss;


 {Combined plots}
 {LONGS}
 If  marketposition = 0  and condition1 and condition2 and condition3 then
begin
      buy NoContracts contract next bar at open stop;
      sell("EB-LLX-1")  2 contract next bar at EB_loss_lg stop;     {to exit
on entry bar at stplosspts}
      sell("EB-PLX")    1 contract next bar at EB_profit_lg limit;     {to
exit  on entry bar at profit}
 end;

 {SHORTS}
 If marketposition = 0  and condition11 and condition12 and condition13 then
begin
     sellshort NoContracts contract next bar at open  stop;
     buytocover ("EB-LSX-1") 2 contract next bar at EB_loss_Short stop;
{to exit on entry bar at stplosspts}
     buytocover ("EB-PSX")   1 contract next bar at EB_profit_Short limit;
{to exit on entry bar at profit}

 end;


>
>
>
>
>
> ----- Original Message ----- 
> From: "Adrian Pitt" <apitt@xxxxxxxxxxxxx>
> To: <omega-list@xxxxxxxxxx>
> Sent: Friday, May 16, 2003 4:30 AM
> Subject: Problem with Code for Exiting on day of Entry
>
>
> > Hi Everyone,
> >
> > I was under the impression that it wasn't possible to exit on the day of
> > entry via a stop, but an associate gave me some code that said it was
> > possible. I altered it slightly to fit my situation but it doesn't seem
> > to be working.  First of all, is my code below actually achievable, and
> > if so, can someone help please by pointing out my logic or coding error?
> >
> > I am basically entering during the day or the open, and then wish to
> > exit either on the close or via a move against my entry price.  The
> > former is for the day of entry only, while the latter is ongoing.
> >
> > -----------------
> >
> > If MarketPosition = -1 then begin
> >  If date = entrydate then begin
> >  If Close > Open then SetExitOnClose;  {exiting on close on day of entry
> > only}
> >  End;
> >  If PositionBasis then
> >   SetStopPosition
> >  Else
> >   SetStopContract;
> >  SetStopLoss(Maxlist(VolStop*Close,5));   {VolStop being a ratio of
> > range}
> > End;
> >
> > ---------------------
> >
> > Regards,
> > Adrian
> >
> >
>