price lines

 

Hi,

I was thinking about price lines, in standard chart we can draw line by hand to see visually the price lines the market have draw, but in an automatic system we can use this lines in a concern of opening or closing orders.

this is what I came with,

I'm happy to share it and hope it will help anyone and lead to conversation about the issue.

looking for price lines
================
go X candles back and look for close price in a layer,
the layer is represent by Z pips so we take the price of the last candle closing price and looking back for Y candles with the closing price inside the layer
if Close[0] equal to 132.09, Z (Z is the representation of our layer) equal to 5 pips, the layer top starting at 132.09+(0.05/2)=132.115 and the lower bottom of the layer finishing at 132.09-

(0.05/2)=132.065, now, if we find that we can "draw" a line between these candles to "our" - last candle.


code
==========

extern int X=500;//number of candle to go back looking for price line
extern double Z = 0.05;//Z is the representation of our layer
extern int Y=3;//how many candles have to be sequentially

double LayerTop = Close[0]+(Z/2);
double LayerButtom = Close[0]-(Z/2);
int CloseSequentially=0;

for(X; X>0; X--)
{
    if(Close[X]<LayerTop && Close[X]>LayerButtom) CloseSequentially++;
    if(CloseSequentially==Y) 
   {
    //here we have to aggragrate the data somehow in order to drow the line
     CloseSequentially=0;
    }
}

if anyone have an idee to improve or similar, I will happy to hear about,

memem.

Reason: