RaptorUK: has the same effect as a Refresh and tries to refresh data from your Broker as well as forcing a tick
I believe it triggers a call to start(). What it has in its buffers is what you get. Not going to do a refresh to broker an more than calling RefreshRates() does.
erzo: For weekend developing! Good idea! Here is my variation (script):
Hi Erzo
I am looking for a solution to speed up a multipair indicator.
I trade mostly by sending trade requests through scripts launched by hotkeys. As you can only run one script on a chart, your script interested me because I could attach it to another chart while it would also send fake ticks to my first/main chart on which I am acively trading using other scripts.
Do you think your script could be used this way for live trading?
Your "TickingAllCharts"-script works wonderful for speeding up my multipair-indicator. I have attached it to a chart of a crosspair I never trade.
I only would like to know/understand if and how your script may or may not interfere with ea's and/or scripts I run on other charts. Could using your script cause some delays for trading orders launched by scirpt or ea attachet to a chart of another symbol?
Alain Verleyen #: You don't need WinAPI to "activate drawing objects like trendline" nowadays. Not even in MQL4.
Thank you for your response.
I am creating new objects with special behaviors by modifying existing ones. For example, I can create a trendline that is always horizontal, allowing users to freely draw levels, or design custom Fibonacci tools, channels, and more.
In this way, I expand the available tools in MT4 for my own use.
To make it user-friendly, I added a button on the chart. When clicked, the mouse becomes ready to draw an object (in this case, a trendline). Once the user draws the trendline, the indicator handles the rest, transforming the standard trendline into an "Always Horizontal Trendline."
But i can not do same thing in MT5, because this code does not works there. maybe we need a MT5 version of aswincmd.mqh file.
Here's the code:
#include <WinUser32.mqh> // Import functions for Windows User32 API (e.g., SendMessageA, PostMessageA, WM_COMMAND)#import "user32.dll"// Import the DLL for user32 API callsint GetAncestor(int, int); // Function to retrieve the root window handle (instead of making multiple GetParent calls)#import
bool horizontalLineEnabled = false; // Flag to check if the horizontal trendline button was clicked//+------------------------------------------------------------------+void UI_ChartEvent(constint id,
constlong &lparam,
constdouble &dparam,
conststring &sparam)
{
// This section handles chart events like object clicks, changes, or creations.if(id == CHARTEVENT_OBJECT_CLICK) // If an object is clicked
{
if(sparam == horizontalTrendlineBtn_name) // Check if the clicked object is the horizontal trendline button
{
int main = GetAncestor(WindowHandle(_Symbol, _Period), GA_ROOT); // Get the root window handle for the current chart
SendMessageA(main, WM_COMMAND, MT4_WMCMD_TRENDLINE, 0); // Send a command to create a trendline
horizontalLineEnabled = true; // Enable the horizontal line processing flag
}
}
// Handle object changes or creationsif(((id == CHARTEVENT_OBJECT_CHANGE)) // If an object is changed
||
((id == CHARTEVENT_OBJECT_CREATE))) // Or if an object is created
{
if(horizontalLineEnabled) // Check if the horizontal line creation flag is enabled
{
if(ObjectType(sparam) != OBJ_TREND) // If the created object is not a trendline, exitreturn;
hLine_TrendlineName = sparam; // Store the name of the trendlineEventSetMillisecondTimer(50); // Set a timer to trigger the OnTimer function after 50 milliseconds
}
}
//+------------------------------------------------------------------+voidOnTimer()
{
// This section is called when the timer set by EventSetMillisecondTimer expiresif(horizontalLineEnabled) // If the horizontal line creation flag is enabled
{
horizontalLineEnabled = false; // Disable the flag since we're processing the trendline// Generate a new unique name for the trendline so that name begin with "s " char// When a trendline has a name starting with "s ", it can be made horizontal every time the user drags it.string newName = "s " + "TrendLine " + (string)(TimeLocal());
// Create a new trendline with the same properties as the clicked trendline but with a new name
TrendCreate(NULL, newName, 0,
(datetime)ObjectGet(hLine_TrendlineName, OBJPROP_TIME1), ObjectGet(hLine_TrendlineName, OBJPROP_PRICE1), // Start time and price
(datetime)ObjectGet(hLine_TrendlineName, OBJPROP_TIME2), ObjectGet(hLine_TrendlineName, OBJPROP_PRICE2), // End time and price
(color)ObjectGet(hLine_TrendlineName, OBJPROP_COLOR), (ENUM_LINE_STYLE)ObjectGet(hLine_TrendlineName, OBJPROP_STYLE), // Line color and style
(int)ObjectGet(hLine_TrendlineName, OBJPROP_WIDTH), // Line widthtrue, true, ObjectGet(hLine_TrendlineName, OBJPROP_RAY), false, 0); // Other trendline properties (ray, etc.)ObjectDelete(hLine_TrendlineName); // Delete the original trendline
hLine_TrendlineName = ""; // Reset the trendline name variableEventKillTimer(); // Stop the timer since the trendline creation process is done
}
}
//+------------------------------------------------------------------+
I am creating new objects with special behaviors by modifying existing ones. For example, I can create a trendline that is always horizontal, allowing users to freely draw levels, or design custom Fibonacci tools, channels, and more.
In this way, I expand the available tools in MT4 for my own use.
To make it user-friendly, I added a button on the chart. When clicked, the mouse becomes ready to draw an object (in this case, a trendline). Once the user draws the trendline, the indicator handles the rest, transforming the standard trendline into an "Always Horizontal Trendline."
But i can not do same thing in MT5, because this code does not works there. maybe we need a MT5 version of aswincmd.mqh file.
Here's the code:
As I said, you don't need this trick (WinAPI), use standard MQL4 and it will become easier to make it work with MT5.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
RaptorUK: has the same effect as a Refresh and tries to refresh data from your Broker as well as forcing a tick
For weekend developing!
Good idea! Here is my variation (script):
Hi Erzo
I am looking for a solution to speed up a multipair indicator.
I trade mostly by sending trade requests through scripts launched by hotkeys. As you can only run one script on a chart, your script interested me because I could attach it to another chart while it would also send fake ticks to my first/main chart on which I am acively trading using other scripts.
Do you think your script could be used this way for live trading?
Looking forward to hear from you.
Hi Erzo
Your "TickingAllCharts"-script works wonderful for speeding up my multipair-indicator. I have attached it to a chart of a crosspair I never trade.
I only would like to know/understand if and how your script may or may not interfere with ea's and/or scripts I run on other charts. Could using your script cause some delays for trading orders launched by scirpt or ea attachet to a chart of another symbol?
It only works if there are indicators placed chart.
Hi everyone, please check codes below:
#define MT4_WMCMD_38175 38175 /* Show/Hide Trade Pannel */
#define MT4_WMCMD_38301 38301 /* Show Depth of market (current symbol) */
this is an interesting discussion
Is this possible to press buy or sell with certain lots?
:)
Hello,
I tried searching for a topic like this for MT5/MQL5, but I couldn't find any.
Could someone please tell me if there is a list of commands similar to the one in aswincmd.mqh for MetaTrader 5?
Can anyone help me find such a file?
I need commands that activate drawing objects like trendline, etc
Hello,
I tried searching for a topic like this for MT5/MQL5, but I couldn't find any.
Could someone please tell me if there is a list of commands similar to the one in aswincmd.mqh for MetaTrader 5?
Can anyone help me find such a file?
I need commands that activate drawing objects like trendline, etc
You don't need WinAPI to "activate drawing objects like trendline" nowadays. Not even in MQL4.
Thank you for your response.
I am creating new objects with special behaviors by modifying existing ones. For example, I can create a trendline that is always horizontal, allowing users to freely draw levels, or design custom Fibonacci tools, channels, and more.
In this way, I expand the available tools in MT4 for my own use.
To make it user-friendly, I added a button on the chart. When clicked, the mouse becomes ready to draw an object (in this case, a trendline). Once the user draws the trendline, the indicator handles the rest, transforming the standard trendline into an "Always Horizontal Trendline."
But i can not do same thing in MT5, because this code does not works there. maybe we need a MT5 version of aswincmd.mqh file.
Here's the code:
Thank you for your response.
I am creating new objects with special behaviors by modifying existing ones. For example, I can create a trendline that is always horizontal, allowing users to freely draw levels, or design custom Fibonacci tools, channels, and more.
In this way, I expand the available tools in MT4 for my own use.
To make it user-friendly, I added a button on the chart. When clicked, the mouse becomes ready to draw an object (in this case, a trendline). Once the user draws the trendline, the indicator handles the rest, transforming the standard trendline into an "Always Horizontal Trendline."
But i can not do same thing in MT5, because this code does not works there. maybe we need a MT5 version of aswincmd.mqh file.
Here's the code: