• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 9:35am
  • Search
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 9:35am
Search
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Search

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

automatic chart pattern drawers for MT4? 36 replies

Automatic Strategies generation that could be auto traded via MT4 0 replies

semi-automatic fibs in MT4? 0 replies

MT4 Automatic Trendlines Indicator 1 reply

MT4 Indicators-Automatic Trendlines 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 6
Attachments: Automatic Arrowhead lines on MT4
Exit Attachments

Automatic Arrowhead lines on MT4

  • Post #1
  • Quote
  • First Post: Edited Jan 25, 2015 3:24am Jan 24, 2015 7:40am | Edited Jan 25, 2015 3:24am
  •  honestknave
  • Joined Nov 2014 | Status: Member | 1,294 Posts
Perhaps this indicator will be of use to somebody.

It will automatically put an arrowhead on any Trendline by Angle that is generated while the indicator is running.

If you move the line or change its color, the arrowhead will be updated.

Please Note: this is a workaround for an inherent shortcoming of MetaTrader 4. Therefore, please do not expect perfection. You must have the font "Wingdings 3" installed on your computer (most Windows PCs should have this font installed).
Attached Image (click to enlarge)
Click to Enlarge

Name: arrows.png
Size: 47 KB
Attached File
File Type: ex4 Arrows.ex4   8 KB | 1,240 download
  • Post #2
  • Quote
  • Feb 23, 2017 5:16pm Feb 23, 2017 5:16pm
  •  anopasilver
  • | Joined Jul 2016 | Status: Junior Member | 2 Posts
thanks mate , let me try it
1
  • Post #3
  • Quote
  • Jan 21, 2018 1:22pm Jan 21, 2018 1:22pm
  •  usmanumar082
  • | Joined Apr 2011 | Status: Member | 63 Posts
Thanks honestknave this is still working.
1
  • Post #4
  • Quote
  • May 6, 2018 10:57pm May 6, 2018 10:57pm
  •  KenWang
  • | Joined Apr 2018 | Status: Junior Member | 1 Post
Thanks! This works perfectly.
1
  • Post #5
  • Quote
  • Oct 20, 2019 1:50pm Oct 20, 2019 1:50pm
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
Is it possible to have the mq4 file?
  • Post #6
  • Quote
  • Nov 4, 2019 1:58pm Nov 4, 2019 1:58pm
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
I'm trying to program an indicator like this, but using trendlines instead of trendbyangles, which don't change when you resize the chart. I have a problem: here is the code. Why doesn't it recognize the value of the price2 always returning 0? some advice? Thanks in advance

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping

//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---

//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // Event identifier
const long& lparam, // Event parameter of long type
const double& dparam, // Event parameter of double type
const string& sparam) // Event parameter of string type
{
if(id==CHARTEVENT_OBJECT_CREATE){

string objname = sparam;
int objtype = ObjectType(objname);
if (objtype == OBJ_TRENDBYANGLE){
datetime time1 = ObjectGet(objname,OBJPROP_TIME1);
double price1 = ObjectGet(objname,OBJPROP_PRICE1);
datetime time2 = ObjectGet(objname,OBJPROP_TIME2);
double price2 = ObjectGet(objname,OBJPROP_PRICE2);
double angle = MathRound(ObjectGet(objname,OBJPROP_ANGLE));

ObjectCreate ("cntr", OBJ_LABEL, 0, 0, 0);
ObjectSet ("cntr", OBJPROP_CORNER, 1);
ObjectSet ("cntr", OBJPROP_XDISTANCE, 381);
ObjectSet ("cntr", OBJPROP_YDISTANCE, 12);
ObjectSetText ("cntr", time1+"|"+price1+"|"+time2+"|"+price2+"|"+angle,10,0,Black);
}

}
}
//+------------------------------------------------------------------+
  • Post #7
  • Quote
  • Nov 4, 2019 2:18pm Nov 4, 2019 2:18pm
  •  Jagg
  • Joined Oct 2006 | Status: Member | 288 Posts
You're still using OBJ_TRENDBYANGLE (and not trend lines) in your code?!

OBJ_TRENDBYANGLE - MQL4 Documentation shows TrendByAngleCreate contains one price/time and one angle. (from here)
  • Post #8
  • Quote
  • Nov 4, 2019 3:04pm Nov 4, 2019 3:04pm
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
yes, trendbyangle is the starting object, because I need the angle to set the arrow. Then I would like to replace it with a normal trendline, but I can't do it without the value of price2. Is only the first part of the code, but I can't go on and I don't understand why I don't get the value of the second price. My request for help was for this.
  • Post #9
  • Quote
  • Nov 5, 2019 3:04am Nov 5, 2019 3:04am
  •  Jagg
  • Joined Oct 2006 | Status: Member | 288 Posts
Drawing a trendline and get the "angle" (better slope) from that object isn't an option? (link)
  • Post #10
  • Quote
  • Nov 5, 2019 4:20am Nov 5, 2019 4:20am
  •  MathTrader7
  • Joined Aug 2014 | Status: Trading | 1,922 Posts
Quoting dani3l380
Disliked
yes, trendbyangle is the starting object, because I need the angle to set the arrow. Then I would like to replace it with a normal trendline, but I can't do it without the value of price2. Is only the first part of the code, but I can't go on and I don't understand why I don't get the value of the second price. My request for help was for this.
Ignored
OBJ_TRENDBYANGLE doesn't have the OBJPROP_PRICE2 property. It is a ray, not a line segment. Which means an object OBJ_TRENDBYANGLE is fully defined by OBJPROP_TIME1, OBJPROP_PRICE1 and OBJPROP_ANGLE.
"Life is what happens when you're busy making other plans." -John Lennon
  • Post #11
  • Quote
  • Nov 5, 2019 6:56am Nov 5, 2019 6:56am
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
Thanks to both of you
  • Post #12
  • Quote
  • Nov 8, 2019 7:38am Nov 8, 2019 7:38am
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
In the end I opted for writing a script.
it works like this:
draw a trendline by angle, launch the script (perhaps through a hotkey is more practical), the trendline by angle will be replaced by a normal trendline with arrowhead; at this point if the trendline is moved or deleted, calling the script everything will be updated.
Note:
- the trendlines will be blue, because the arrows are only blue;
- arrows will be drawn only for the angle from 90 ° to 270 °, so to speak towards the right side of the graph;
- the images of the arrows must be saved in the images folder of the platform.
I enclose everything maybe it can be useful to someone.
Thanks for collaboration.
Attached Files
File Type: rar arrow.rar   77 KB | 12 downloads
File Type: mq4 Plot_Arrow.mq4   3 KB | 14 downloads
  • Post #13
  • Quote
  • Nov 8, 2019 9:46am Nov 8, 2019 9:46am
  •  Jagg
  • Joined Oct 2006 | Status: Member | 288 Posts
Quoting dani3l380
Disliked
In the end I opted for writing a script. it works like this: draw a trendline by angle, launch the script (perhaps through a hotkey is more practical), the trendline by angle will be replaced by a normal trendline with arrowhead; at this point if the trendline is moved or deleted, calling the script everything will be updated. Note: - the trendlines will be blue, because the arrows are only blue; - arrows will be drawn only for the angle from 90 ° to 270 °, so to speak towards the right side of the graph; - the images of the arrows must be saved...
Ignored
Doing it this way is really limited (to a white background, always the need for runnig the script again, ...) and the need for >180 bmp files is insane

I thought more about using "Wingdings 3" font (as honestknave is doing it with his indicator), using the letters p and q with the correct angle for example
Attached Image
  • Post #14
  • Quote
  • Nov 8, 2019 10:35am Nov 8, 2019 10:35am
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
Quote
Disliked
180 bmp files is insane
unfortunately I know it, three hours of my life
How can I set these characters as a bmp file? What is the path?
  • Post #15
  • Quote
  • Nov 8, 2019 10:58am Nov 8, 2019 10:58am
  •  Jagg
  • Joined Oct 2006 | Status: Member | 288 Posts
Quoting dani3l380
Disliked
{quote} unfortunately I know it, three hours of my life How can I set these characters as a bmp file? What is the path?
Ignored
No bmp.... you only add a text object with the mentioned fontname and using "p" / "q" as text. That's all!

Inserted Code
ObjectCreate(0, objName, OBJ_TEXT, 0, closeTime, closePrice+point2pip(0.3));
ObjectSetString(0, objName, OBJPROP_FONT, "Wingdings 3");
ObjectSetString(0, objName, OBJPROP_TEXT, "p");
ObjectSetDouble(0, objName, OBJPROP_ANGLE, 23);
....
  • Post #16
  • Quote
  • Last Post: Nov 9, 2019 5:13am Nov 9, 2019 5:13am
  •  dani3l380
  • | Joined Mar 2017 | Status: Member | 24 Posts
Thank you very much for your advice, as you may have guessed I am not a programmer, even if I can untangle myself a little with the codes. English is not my language and finding information is not always easy even using a translator. However I have readjusted the code with your welcome explanations.
Now draw arrows in all directions and based on the color of the trendline by angle.
The choice of a limiting script, instead of an indicator, is given by the fact that I keep many graphics open with various ea and indicators and sometimes the platform slows down. For this reason it is preferable for me to write a script only when I need it, also because I am not continuously shooting arrows .
Many thanks again.
Attached File
File Type: mq4 Plot_Arrow_v1.1.mq4   3 KB | 13 downloads
Thread Tools Search this Thread
Show Printable Version Show Printable Version
Email This Thread Email This Thread
Search this Thread:

Advanced Search

  • Platform Tech
  • /
  • Automatic Arrowhead lines on MT4
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2019