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

Re: Code - help please



PureBytes Links

Trading Reference Links


Hi, Noel:

I think I'd try something along the lines of the following (untested code):

Input: 

PcntStop(1),
PcntProf(1);


Var: 

LevAbovL(0),
LevBeloL(0),
LevAbovS(0),
LevBeloS(0);


If MarketPosition = 1 and BarsSinceEntry = 1 then begin
  LevAbovL = EntryPrice * (1 + PcntProf/100);
  LevBeloL = EntryPrice * (1 - PcntStop/100);
End;

If MarketPosition = -1 and BarsSinceEntry = 1 then begin
  LevAbovS = EntryPrice * (1 + PcntStop/100);
  LevBeloS = EntryPrice * (1 - PcntProf/100);
End;

If MarketPosition = 1 and (H >= LevAbovL or L <= LevBeloL) then exitlong
else if MarketPosition = -1 and (L <= LevBeloS or H >= LevAbovS) then exitshort;
 





 ---- you wrote: 
> Hi
> 
> Being a newbe- ish  to TS2000i .. i wrote this 
> code which should give percentage exits for  trading stocks.
> but it does not seem to work properly.
> 
> Any help would be greatly appreciated.
> 
> Many thanks
> 
> Noel
> 
> 
> Input: PcntStop(1), PcntProfit(1);
> 
> Var: LongPrice(0),ShortPrice(0),LongStop(0),ShortStop(0);
> 
> LongPrice = EntryPrice + ((EntryPrice * PcntProfit)/100);
> ShortPrice = EntryPrice - ((EntryPrice * PcntProfit)/100);
> 
> LongStop = EntryPrice - ((EntryPrice * PcntStop)/100);
> ShortStop = EntryPrice + ((EntryPrice * PcntStop)/100);
> 
> if high >= LongPrice or low <= LongStop then exitlong;
> if low <= ShortPrice or high >= ShortStop then exitshort;
> 
> 
> 
> 
>