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

TS4 to TS 2000i code problem



PureBytes Links

Trading Reference Links

Hi!

Can someone tell me what is going own here,

This code runs ok in TS4, but when I port it to
TS2000i or TS7.1 it generates the correct signals in
the correct 
places, but no profit target or stop losses are
generated what so ever?

any help appreciated

Eduardo J Motta


Inputs:  Price(Close),     { series to performanalysis
on }
      Len1(3),     { fast MA length }
      Len2(21);     { slow MA length }     

Variables:
FMA(0),SMA(0),OkToBuy(True),OkToSell(True),mp(0),ep(0);
Variables:Prft1(0),Prft2(0),Stp1(0),Stp2(0);
FMA=Average(Price,Len1); {Fast Moving Average}
SMA=Average(Price,Len2); {Slow Moving Average}     


{==== Entry Orders ===}
if FMA > SMA and close > SMA and OkToBuy=true then
begin
    Buy("Buy") 2 Contracts at Close; 
    OkToBuy=False;
    OkToSell=True;
   Mp=1;
   ep=C;
end;

If Mp=1 then begin
   Prft1=ep +50;
   Prft2=ep +100;     
   Stp1=ep -50;
   Stp2=ep -100;
     Exitlong("ExPrftl1") 1 contract total from
Entry("Buy") at Prft1 limit;
     Exitlong("ExPrftl2") 1 contract total from
Entry("Buy") at Prft2 limit;
     Exitlong("ExStpl1") 1 contract total from
Entry("Buy") at Stp1 stop;
     Exitlong("ExStpl2") 1 contract total from
Entry("Buy") at Stp2 stop;
end;


if FMA < SMA and close < SMA and OkToSell=true then
begin
    Sell("Sell") 2 contracts at Close;
    OkToSell=False;
    OkToBuy=True;
   Mp=-1;
   ep=c;
end;

If Mp=-1 then begin
   Prft1=ep -50;
   Prft2=ep -100;     
   Stp1=ep +50;
   Stp2=ep +100;
   Exitshort("ExPrfts1") 1 contract total from
Entry("Sell") at Prft1 limit;
     Exitshort("ExPrfts2") 1 contract total from
Entry("Sell") at prft2 limit;
     Exitshort("ExStps1") 1 contract total from
Entry("Sell") at Stp1 stop;
     Exitshort("ExStps2") 1 contract total from
Entry("Sell") at Stp2 stop;
end;
If AtCommentaryBar then begin
   vars:str("");
   str="Mp= "+NumToStr(Mp,0)+NewLine;
   str=str+"OkToBuy=
"+NumToStr(IFF(OkToBuy,1,0),0)+NewLine;
   str=str+"OkToSell=
"+NumToStr(IFF(OkToSell,1,0),0)+NewLine;
   if mp=1 then str=str+"Long ep is
"+NumToStr(ep,0)+NewLine
        Else 
   str=str+"Short ep is "+NumToStr(ep,0)+NewLine;
   str=str+"Prft1= "+NumToStr(Prft1,0)+NewLine;
   str=str+"Prft2= "+NumToStr(Prft2,0)+NewLine;
   str=str+"Stp1= "+NumToStr(Stp1,0)+NewLine;
   str=str+"Stp2= "+NumToStr(Stp2,0);
   commentary(str);
end;