hi,

yes this can be programmed similarly but other than food for thought in my 
opinion not worth putting too much time into,

regards, Ed



  ----- Original Message ----- 
  From: Anthony C. Abry 
  To: [email protected] 
  Sent: Thursday, January 08, 2009 2:00 PM
  Subject: Re: [amibroker] Top Stop Exit programming question


  Ok, I found it.

  The entry is

  Buy = C > MA(C,100);  

  rather than the cross(C,MA(C,100));

  Volker Knapp actually depicts two methods in the Active Trader Magazine 
article, one for trend and one range (i.e. counter trend).

  The counter trend entry is:

  Long at market if todays low is 10% below the high 4 days ago
  Initial Exit: limit order at 2.5 * ATR(10) plus abs(todays C minus yesterdays 
C)
  Trailing Exit: If C is the highest of the past 10 days, raise the limit order 
by the abs(C - yesterdyas C). If it fails to make a 10 days high close, lower 
it by the same amount.

  He says that the method underperforms a Buy and Hold of the SP500, however, 
he likes that the equity curve looks smoother.

  Anthony


  Edward Pottasch wrote: 

     

    ok good. Maybe if you provide some more details on the stop method or where 
it seems to go wrong I could help. On a first glanse the stop looks interesting 
but some tests do not give very good results. So maybe I missed some details of 
how it should work. Guess the idea is to let winners run and cut losers short. 
But is seems to cut of winners too early.

    regards, Ed





      ----- Original Message ----- 
      From: Anthony C. Abry 
      To: [email protected] 
      Sent: Wednesday, January 07, 2009 7:37 AM
      Subject: Re: [amibroker] Top Stop Exit programming question


      Ed,

      I just saw your answer now. Thank you so much. 

      I was unable to reproduce the exact chart as in the AT magazine, however, 
the white stop array line looks similar to the ones in the article. A little 
tweaking, therefore, and it should be done.

      Thanks again.



      Edward Pottasch wrote: 

         

        hi,

        you indeed need a loop to program this. Ararys only will not do it. 
Below the code from how I understand it from your text.

        regards, Ed


        procedure sell_proc(Buy,BuyPrice,stp,hhvstp) 
        { 

        global BuyAdjusted; 
        global BuyPriceAdjusted; 
        global SellAdjusted; 
        global SellPriceAdjusted; 
        global stopArray; 


        BuyAdjusted = 0; 
        BuyPriceAdjusted = 0; 
        SellAdjusted = 0; 
        SellPriceAdjusted = 0; 
        stopArray = Null; 

        delay = 1; 
        slip = 0.0; 

        for( i = 1; i < BarCount; i++ ) 
        { 
            
           if ( Buy[ i ]) 
           { 

              BuyAdjusted[ i ] = 1; 
              BuyPriceAdjusted[ i ] = BuyPrice[ i ] + slip; 
              stopArray[ i ] = BuyPriceAdjusted[ i ] + stp[ i ]; 
               
              for (j = i + delay; j < BarCount; j++) 
              {    
               
                 if (hhvstp[ j ]) 
                 { 
                  
                    stopArray[ j ] = stopArray[ j - 1 ] + abs(C[j - 1] - C[j - 
2]); 
                  
                 } 
                 else 
                 { 

                    stopArray[ j ] = stopArray[ j - 1 ] - abs(C[j - 1] - C[j - 
2]);           
                  
                 } 
                  

                 if (C[ j ] > stopArray[ j ]) 
                 { 
                  
                    SellAdjusted[ j ] = 1; 
                    SellPriceAdjusted[ j ] = C[ j ] - slip; 
                    i = j; 
                    break; 
                  
                 }          
                 else if (j == BarCount - 1) 
                 { 
                           
                    i = BarCount; 
                           
                 } 
              } 
           } 
        } 

        } 

        SetBarsRequired(10000, 10000); 
        Buy = Cross(C,MA(C, 100)); Buy = Ref(Buy,-1); 
        BuyPrice = O; 

        // set initial exit limit at buy 
        stp = Ref(ATR(14)*4.5 + abs(C-Ref(C,-1)),-1); 
        // hhvstp is 1 when closing price is highest of the past 20 days, else 
0 
        hhvstp = Ref(HHV(C,20) == C,-1); 

        sell_proc(Buy,BuyPrice,stp,hhvstp); 

        Buy = BuyAdjusted; 
        BuyPrice = BuyPriceAdjusted; 
        Sell = SellAdjusted; 
        SellPrice = SellPriceAdjusted; 

        SetChartOptions(0, chartShowDates); 
        GraphXSpace = 5; 
        Plot(C,"C",1,64); 

        Plot(stopArray,"stopArray",colorWhite,1); 
        Plot(MA(C,100),"ma",colorYellow,1); 

        PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15); 
        PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,L,-15); 
        
PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,BuyPrice,0); 

        PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15); 
        
PlotShapes(IIf(Sell,shapeHollowDownArrow,shapeNone),colorWhite,0,H,-15); 
        
PlotShapes(IIf(Sell,shapeHollowSmallCircle,shapeNone),colorWhite,0,SellPrice,0);
 





          ----- Original Message ----- 
          From: Anthony C. Abry 
          To: [email protected] 
          Sent: Tuesday, December 30, 2008 6:01 AM
          Subject: [amibroker] Top Stop Exit programming question


          Hi,

          I am trying to program the Top Stop Exit as described by Volker Knapp 
in 
          the September 08 edition of Active Trader Magazine.

          The entry rule is a basic moving average cross (for the trend 
strategy) 
          over but the exit is giving me trouble.

          The exit uses a limit order which adjusts up or down depending on the 
          volatility.

          The rules are:

          Limit exit: 4.5 times the ATR(14) plus the absolute value of todays 
          closing price minus yesterdays closing price.
          If the closing price is highest of the past 20 days, raise the exit 
by 
          the absolute value of todays closing price minus yesterdays closing 
price.
          If the price fails to make a new 20 day high, lower the exit price by 
          the same amount.

          Any help would be appreciated.

          Thank you.

          /* from active trader mag. sep 08, p.54 */

          SetTradeDelays(1,0,1,0);

          BuyPrice = C;

          Buy = Cross(C,MA(C, 100));

          Entryprice = 0;

          Limitexitprice = 0;

          for (i=0; i < BarCount; i++)
          {

          if (Entryprice == 0 AND Buy[i] == 1)
          {
          Entryprice = BuyPrice[i];
          Limitexitprice = Entryprice + ATR(14)*4.5 + abs(C-Ref(C,-1));
          }
          else

          if (Entryprice > 0 AND H[i] > Limitexitprice[i])
          {
          Sell[i] =1;
          SellPrice[i] = Limitexitprice;
          Entryprice = 0;
          }
          else

          if (Entryprice > 0)
          {
          Limitexitprice = IIf(C > HHV(C,20),
          Limitexitprice + ATR(14)*4.5 + abs(C-Ref(C,-1)),
          Limitexitprice + ATR(14)*4.5 - abs(C-Ref(C,-1)));
          }

          }

          Sell = Cross(C, Limitexitprice);

          Buy = ExRem(Buy,Sell);
          Sell = ExRem(Sell,Buy);




   

Reply via email to