Need help in identifying Trendline Crossover Price -Amibroker?

amar_gr

Active Member
#1
I am trying to create an exploration in which I need to identify
the price level at which a TL has been crossed.

I have a manually drawn a trendline which has been given RE as study ID
Here I am using the following code which returns the close price on the day of the TL crossover.

BrkoutValue = Cross(Close, Study("RE",id))

Thanks in advance

Amar.
 

colion

Active Member
#2
I'm not sure what you are looking for. Cross() does not return C but rather either a true or false (1 or 0) when the trendline crosses C. If C is the wrong "cross" value what is the "right" one?
 

amar_gr

Active Member
#3
I'm not sure what you are looking for. Cross() does not return C but rather either a true or false (1 or 0) when the trendline crosses C. If C is the wrong "cross" value what is the "right" one?
My mistake, here's the code, the objective is to identify the price at which the TL gets crossed. for ex on a given day, the down sloping Trend line is crossed and price closes above it. The given bar is crossed at price of 63 and the bar closes at 67. The following code returns 67, while I need the code to return 63.

Breakout = Cross(ATRIGGER, Study("RE",id)) ;
BrkoutValue = ValueWhen(Breakout, Close);

I want to create a exploration where I can identify breakouts which have occurred within the past X days and have tested or closed near their breakout level today.

Thanks in advance
 

colion

Active Member
#4
You are limited by the data that you have. Are you using EOD, intraday (e.g., 5 minute), or tick data? For EOD and intraday data what you want to do is not possible as the only data information you have is O, H, L, C and Cross() will be defined in those terms. The bar or candle that you are looking at is simply a drawing based on those four numbers. I don't use tick data but assume that the O, H, L, C array fields are equal so that would give you the crossing price.

If you use EOD or intraday data and are trying to get the exact price of the cross then you will have to develop an alogorithm that estimates what the price is at that point or perhaps which of the data fields to use based on their relative values (i.e., O > H, O < H, C > H, etc.). This will not be exactly the price but it would be a little bit better than just using a fixed data field such as C. However, going to smaller time frames will let you approach tick data while simply using C (or any other data field).

You might want to think about the reality of the situation and how precise you need or want to be. I think most find that EOD or intraday C are adequate.
 

amar_gr

Active Member
#5
Thanks Colion,

I was hoping there would be some straightforward way to achieve this. Anyway, thanks & really appreciate your inputs. Writing an algorithm is way beyond my AFL skills, I am a newbie on this rather more of a cut & paste programmer.

Thanks to the internet am able to buildup on creating small programs by application than by structured learning.
 

Similar threads