View Single Post
  #2 (permalink)  
Old 05-07-2006, 07:06 AM
elihayun's Avatar
elihayun elihayun is offline
Senior Member
 
Join Date: Jan 2006
Posts: 379
elihayun is on a distinguished road
Quote:
Originally Posted by Gavner
Hello all-
I'm new to programming and this forum, and yesterday I wrote a simple EA based on the Parabolic SAR (Buy when it's below current price, sell when it's above). I have already written trailing stops into the program, but currently it initiates a new order in the same direction that I just closed something with the trailing stop (since the SAR hasn't switched over yet). I don't want this; if the last closed trade was a sell, I want the program to wait for appropriate conditions (SAR below price) to initiate a buy, and vice versa. I'm sure there's a simple way to do this, but I can't figure it out .
Thanks a bunch in advance,
Gavner
I think that u have to check the the SAR is blow price but also the previous SAR is above previous close price to plase a buy order. Sothing like this
// Check for BUYS
if((Ask>SARCurrent) && (iClose[1] < SARPrevious))

and the opposite for sell
// Check for SELLS
if((Bid<SARCurrent) && (iClose[1] > SARPrevious))
Reply With Quote