Jump to content

TrendlineRange Indicator


4xmeter

Recommended Posts

You have to draw a trendline of your swing Price movement that you are measuring; and write down the number of the trendline that is given when you place you mouse over it in the input of the indicator under Index TrendLine _______.

 

I can not qualify the performance of this indicator, as of today; however, it is in the right direction for (Sharpeyes 8-) )!

Could some one make it more user friendly! Please!

 

 

//+------------------------------------------------------------------+

//| TrendLineRange.mq4 |

//| Ñîêðàòèëèí Àëåêñåé |

//| [email protected] |

//+------------------------------------------------------------------+

#property copyright "Ñîêðàòèëèí Àëåêñåé"

#property link "[email protected]"

 

#property indicator_chart_window

//---- input parameters

extern int PointsRange1=20; //1-îå ðàññòîÿíèå äî òðåíäîâîé ëèíèè

extern int PointsRange2=10; //2-îå ðàññòîÿíèå äî òðåíäîâîé ëèíèè

extern int PointsRange3=5; //3-åå ðàññòîÿíèå äî òðåíäîâîé ëèíèè

extern string IndexTrendLine; //Èíäåêñ òðåíäîâîé ëèíèè â ñïèñêå îáúåêòîâ

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

 

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

static int S1,S2,S3; //Ñ÷åò÷èêè ñèãíàëîâ

string TrendLine="Trendline "+IndexTrendLine; //Äîáàâëåíèå èíäåêñà òåíäîâîé ëèíèè ê "Trendline"

double Price=Bid; //Òåêóùàÿ öåíà

double TrendLineValue=NormalizeDouble(ObjectGetValueByShift(TrendLine,0),Digits); //Òåêóùåå çíà÷åíèå òðåíäîâîé ëèíèè

 

int Range=MathAbs((NormalizeDouble(Price,Digits)-TrendLineValue)*MathPow(10,Digits));

//Âû÷èñëåíèå ðàññòîÿíèÿ ìåæäó òåêóùåé öåíîé è òðåíäîâîé ëèíèåé

 

Comment("Range=",Range);

 

if (Range<=PointsRange1 && Range>PointsRange2 && S1==0) //Åñëè òåêóùåå ðàñññòîÿíèå <= ðàññòîÿíèÿ1 è > ðàññòîÿíèÿ2

{ //ñèãíàë íà ýòîì ïðîìåæóòêå íå ïîäàâàëñÿ, òî ïîäàåì îäèí ñèãíàë.

Alert("Range=",Range," Price=",Price," TrendLine=",TrendLineValue);

S1=1; S2=0; S3=0; //Îáíóëåíèå ñ÷åò÷èêîâ

}

else

if (Range<=PointsRange2 && Range>PointsRange3 && S2==0) //Åñëè òåêóùåå ðàñññòîÿíèå <= ðàññòîÿíèÿ2 è > ðàññòîÿíèÿ3

{ //ñèãíàë íà ýòîì ïðîìåæóòêå íå ïîäàâàëñÿ, òî ïîäàåì îäèí ñèãíàë.

Alert("Range=", Range, " Price=", Price, " TrendLine=",TrendLineValue);

S1=0; S2=1; S3=0; //Îáíóëåíèå ñ÷åò÷èêîâ

}

else

if (Range<=PointsRange3 && S3==0) //Åñëè òåêóùåå ðàñññòîÿíèå <= ðàññòîÿíèÿ3

{ //ñèãíàë íà ýòîì ïðîìåæóòêå íå ïîäàâàëñÿ, òî ïîäàåì îäèí ñèãíàë.

Alert("Range=", Range, " Price=", Price, " TrendLine=",TrendLineValue);

S1=0; S2=0; S3=1; //Îáíóëåíèå ñ÷åò÷èêîâ

}

 

return(0);

}

//+------------------------------------------------------------------+

Link to comment
Share on other sites

Re: TrendlineRange Indicator

 

Here are the instructions by the Author.

 

The matter of the indicator is as follows: when the price approaches to the support/resistance line by 20, 10 and 5 points (these are default values that can be changed by desire), the indicator will produce one signal (Alert) if the price is located in the spaces before the trend line (20<=Price<10), (10<=Price<5), (5<=Price=0), but doesn't bury the user with signals at every tick. The only thing is that the indicator will produce several signals when the price moves from one space into another.

 

It also shows the current distance from the price to the support/resistance line in the upper left corner (Comment).

 

 

The following is contained by the signal:

 

Range - distance from the price to the support/resistance line;

 

Price - current price;

 

TrendLine - current location of the support/resistance line.

 

The following must be introduced in settings:

 

PointsRange1 - the first (largest) distance to the trend line, at which the signal will be produced;

 

PointsRange2 - the second (medium) distance to the trend line, at which the signal will be produced;

 

PointsRange3 - the third (small) distance to the trend line, at which the signal will be produced;

 

IndexTrendLine - index, exactly the index of the trend line, which you can see in the list of objects.

 

The values of distances 1, 2 and 3 must be introduced in decreasing order!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...