SAR is already "tommorows" value, i.e. the value that should be used for 
placing tommorrows stop orders.

Best regards,
Tomasz Janeczko
amibroker.com
  ----- Original Message ----- 
  From: Tomasz Lutelmowski 
  To: [email protected] 
  Sent: Friday, December 12, 2008 12:44 PM
  Subject: [amibroker] calculating tomorrow's value of SAR


  Hello,

  I need to calculate future value for SAR, Ref(SAR,1) works good until last 
bar, and the last bar is most important for me because I want to use it in the 
system which relies on tomorrow's open price. In short, I would like to 
imlement this formula in AmiBroker:

  SAR next day = SAR today + AccelerationFactor( highest high reached yesterday 
- SAR today)  // got this formula here

  This is what I have so far:

  // SAR today
  AF = 0.02;
  tSAR = SAR(AF,0.2);

  // This is number of bars after last "swap" of trend
  barSAR = Min(BarsSince(Cross(tSAR,H)),BarsSince(Cross(L,tSAR)))+1;

  // And finally here is my attempt to calculate next day SAR,
  // but results are not always the same as AmiBroker SAR ;(
  // I guess I have to skip acceleration in some cases, but 
  // don't know how to implement this in AB...
  nSAR = tSAR + AF * barSAR * (LLV(L,barSAR) - tSAR); 

  Could you help me with this ? 

  Best regards,
  Tomek
   

Reply via email to