James, Don't feel bad ... everyone experiences these aha moments ...
just one comment... not sure about this, but your first line may need to be: BuyStp = Ref(HHV(H,15),-1); //verify the values you get to make sure ----- Original Message ----- From: James To: [email protected] Sent: Monday, September 15, 2008 11:41 AM Subject: Re: [amibroker] Buy/Sell price on a stop Ara, I feel like an idiot for not trying this before posting, but I think this works. I wanted to post to the list as it may be my first chance to give instead of take. BuyStp = HHV(Ref(H,-1),15); Buy = Cross (High, BuyStp); BuyPrice = Max (BuyStp, L)+ (2*Ticksize); This is giving me 2 ticks slippage on the buy. ----- Original Message ---- From: Ara Kaloustian <[EMAIL PROTECTED]> To: [email protected] Sent: Monday, September 15, 2008 10:13:11 AM Subject: Re: [amibroker] Buy/Sell price on a stop James, you could use tick value indirectly. You would need to define them and then reference them. Since you are talking about tick values, you are considering commodities / futures which are moreless limited in numbers ... so here is the concept. You will need to do some string manipulation to get the root symbol ("ES" from "ESU8 for example) in order to get the associations correct. Define: ES_Tick = 0.25; etc... Root = StrLeft(Name( ),2); // from "ESxx", it will return "ES" if (Root == "ES") TickValue = ES_Tick; // will need multiple of these statements - one for each symbol used. BuyPrice = iif(Buy,BuyStp + TickValue,0); ----- Original Message ----- From: James To: [EMAIL PROTECTED] ps.com Sent: Monday, September 15, 2008 7:45 AM Subject: Re: [amibroker] Buy/Sell price on a stop Ara, Point 1 I can live with. Point 2 is why I would like to use the tick value. When testing one contract at a time, I can handle this issue buy adding 1 or 2 or 3 etc tick values to the commission. But if I want to test a portfolio of contracts, the tick value would be helpful because they are all different. Do you think it is possible to use tickvalue in the AFL formula? James ----- Original Message ---- From: Ara Kaloustian <[EMAIL PROTECTED] com> To: [EMAIL PROTECTED] ps.com Sent: Sunday, September 14, 2008 10:29:22 AM Subject: Re: [amibroker] Buy/Sell price on a stop The slippage seems variable since the bid ask spread varies with time of day. Second, 1 Tick may have different values for different issues ... so assuming you are handling ONE issue at a time you just write the slippage you assume: BuyPrice = iif(Buy,BuyStp + somevalue,0); ----- Original Message ----- From: James To: [EMAIL PROTECTED] ps.com Sent: Sunday, September 14, 2008 8:06 AM Subject: [amibroker] Buy/Sell price on a stop Could someone point me in the right direction for the AFL in calculating the slippage of buying or selling on a stop. I searched ticksize and point value to no avail. For example: BuyStp = HHV(Ref(H,-1),15); Buy = Cross (High, BuyStp); BuyPrice = Max (BuyStp, L); I want BuyPrice = Max (BuyStp, L)+ 1 tick ; In this case of buying on a stop at BuyStp, you will almost never get filled at BuyStp because the ask will be at least 1 tick higher, therefore I would like to adjust the buy price by a certain number of ticks. Thank you, James
