ozzyapeman wrote:
Actually I do use Applystop()in a good number of my formulas. Any
suggestions for such cases?

That is what I came out with  (OHLC build on Bid price):

|
SetCustomBacktestProc( "" );
*if* ( Status( "action" ) == *actionPortfolio* )
{
   bo = GetBacktesterObject();
   bo.PreProcess();
   slipage = *TickSize*;
   spread = 2 * *TickSize*;
*for* ( bar = 0; bar < *BarCount*; bar++ )
   {
*for* ( sig = bo.GetFirstSignal(bar); sig; sig = bo.GetNextSignal(bar) )
       {
        symbol = sig.symbol;
        hi = Foreign(symbol, "H");
        lo = Foreign(symbol, "L");
*if* ( sig.IsExit() )
           {
           *if* ( sig.isLong)
           {
              realexitprice = sig.price - slipage;
              *if*( realexitprice >= lo[bar] && realexitprice <= hi[bar])
              {
                 sig.price = realexitprice;
bo.ExitTrade(bar,sig.symbol,sig.Price); // I'm not sure if it is needed
              }
              *else*
              sig.price = -1;
           }
           *else*
           {
              realexitprice = sig.price + slipage;
*if* ( realexitPrice >= lo[bar]+ 0.5*spread && realexitprice <= hi[bar]+0.5*spread)
              {
                 sig.price = realexitprice;
bo.ExitTrade(bar,sig.symbol,sig.Price); // I'm not sure if it is needed
              }
              *else*
              sig.price = -1;
           }

           }
       }

       bo.ProcessTradeSignals( bar );
   }

   bo.PostProcess();
}
|

Reply via email to