Boa tarde Izidro…grato pelo retorno.
Então…desse jeito o stop tb fica estatico.
os stops e os alvos estão dentro do buyposition>0 e sellposition>0.
Segue o codigo:
Const
  // Configuraçao
  RespiroTicks        = 0;
  HoraEntradaInicio   = 0900;
  HoraEntradaFim      = 1740;
  HoraFechamento      = 1740; {Horário da Penúltima Barra}
PARAMETRO
nadx(25.0);
escalada(80.0);
Alvofibo(1.27);
var
  SinalC, SinalV : Booleano;
  R : Real;
  EntradaC, StopC, AlvoC : Real;
  EntradaV, StopV, AlvoV : Real;
  VADX:FLOAT;
  mmvol:float;
  rally:float;
  stopmm9:float;
Inicio
  {Cálculos}
  R := RespiroTicks * MinPriceIncrement;
  VADX:=ADX(9,0);
  mmvol:=(media(21,volume));
  rally:=escalada*minpriceincrement;
  stopmm9:=media(9,close);
  {Setup}
  SinalC := (media(9,close) > media(21,close))
      and (vADX > nADX)
      //and (volume > mmVol)
      and (close > media(9,close))
      //AND (ABS(close[0] - open[2]) < rally)
      //and (media(9,close[2]) < media(9,close[1]))
      and (media(9,close[1]) < media(9,close))
      //and (media(21,close[2]) < media(21,close[1]))
      and (media(21,close[1]) < media(21,close))
      //AND (NIREV > 1)
      //AND (NIREV[2] > NIREV[1])
      //AND (NIREV[1] > NIREV[0])
      //and (close[2]-open[2]>0)
      //and (close[1] - open[1] > 0)
      //and (close[0] - open[0] > 0)
      //and (low[2] < low[1])
      and (low[1] < low); 
  SinalV := (media(9,close) < media(21,close))
      and (vADX > nADX)
      //and (volume > mmVol)
      and (close < media(9,close))
      //AND (ABS(open[2] - close[0]) < rally)
      //and (media(9,close[2]) > media(9,close[1]))
      and (media(9,close[1]) > media(9,close))
      //and (media(21,close[2]) > media(21,close[1]))
      and (media(21,close[1]) > media(21,close))
      //AND (NIREV < 1)
      //and (Nirev[2] < Nirev[1])
      //and (Nirev[1] < Nirev[0])
      //and (close[2]-open[2]<0)
      //and (close[1] - open[1] < 0)
      //and (close[0] - open[0] < 0)
      //and (low[2] > low[1])
      and (low[1] > low);
  {Coloraçao}
  Se SinalC entao PaintBar(clVerde);
  Se SinalV entao PaintBar(clVermelho);
  {Busca Entrada}
  Se (BuyPosition = 0) e (SellPosition = 0) e 
  (Time >= HoraEntradaInicio) e (Time < HoraEntradaFim) entao
  inicio
    {Compra}
    Se SinalC entao
      inicio
        EntradaC := Maxima + R;
        StopC := stopmm9;
        AlvoC := Maxima + (Range * AlvoFibo);
        BuyStop(EntradaC,EntradaC);
    fim;
    {Venda}
    Se SinalV entao
      inicio
        EntradaV := Minima - R;
        StopV := stopmm9;
        AlvoV := Minima - (Range * AlvoFibo);
        SellShortStop(EntradaV, EntradaV);
      fim;
  fim;
  {Se estiver comprado - buscar saída}
  Se (BuyPosition > 0) entao
    inicio
      SellToCoverLimit(AlvoC);
        if (close<stopC) then
        begin
        SellToCoveratmarket;
        end;    
    fim;
  {Se estiver vendido - buscar saída}
  Se (SellPosition > 0) entao
    inicio
      BuyToCoverLimit(AlvoV);
        se (close>stopV) then
        begin 
        BuyToCoveratmarket;
        end;
    fim;
  {Fechar Posiçoes no Final do Dia}
  Se (Time >= HoraFechamento) entao ClosePosition;
Fim;