Hello, I'm a new coder who is learning by myself so this might be a noob question but please bear with me...
What I want to do ===> create a custom indicator that has some hotkeys (for example by pressing Key "A" or "CTRL+A") that will execute a script or some other function.
Question =====> If I use #include Virtualkeys.mqh + WinUser.mqh and use OnChartEvent Keydown + switch case to execute this ( i am using already #defined keys in Virtualkeys.mqh for the case);
1. Will this hotkey work across platforms (windows/MAC OS/Linux)? ( I think Winuser imports user32.dll, not sure if MAC OS supports that)
2. Will this hotkey work across Keyboard layouts/regional settings (US QWERTY/US DVORAK)?
3.If it does not, Is there a way to make it happen? (I've been searching for a way to get a key as a input and set that into the code but haven't still found a way to do that)
4.Also if there is a way to get a key as a user input and use that key for the switch, please enlighten me guys.
Thanks in advance, and my apologies if this is a frequently asked noob question....
Hello, I'm a new coder who is learning by myself so this might be a noob question but please bear with me...
What I want to do ===> create a custom indicator that has some hotkeys (for example by pressing Key "A" or "CTRL+A") that will execute a script or some other function.
Question =====> If I use #include Virtualkeys.mqh + WinUser.mqh and use OnChartEvent Keydown + switch case to execute this ( i am using already #defined keys in Virtualkeys.mqh for the case);
1. Will this hotkey work across platforms (windows/MAC OS/Linux)? ( I think Winuser imports user32.dll, not sure if MAC OS supports that)
2. Will this hotkey work across Keyboard layouts/regional settings (US QWERTY/US DVORAK)?
3.If it does not, Is there a way to make it happen? (I've been searching for a way to get a key as a input and set that into the code but haven't still found a way to do that)
4.Also if there is a way to get a key as a user input and use that key for the switch, please enlighten me guys.
Thanks in advance, and my apologies if this is a frequently asked noob question....
MetaTrader is a Windows application and will run in an emulated or virtualised environment under Mac/Linux, so probably most key sequences will be emulated as the same. There is no need to use "user.dll". The OnChartEvent() function can handle keyboard events.
No, the key sequences will NOT be the same across different layouts.
There are some keys that will remain the same over most of the regional layouts but not all. The best way to handle this is to allow the user to customise and choose their own sequences.
Yes! Simply keep a running state in a variable and each time the key is pressed, you toggle that boolean state.
MetaTrader is a Windows application and will run in an emulated or virtualised environment under Mac/Linux, so probably most key sequences will be emulated as the same. There is no need to use "user.dll". The OnChartEvent() function can handle keyboard events.
No, the key sequences will NOT be the same across different layouts.
There are some keys that will remain the same over most of the regional layouts but not all. The best way to handle this is to allow the user to customise and choose their own sequences.
Yes! Simply keep a running state in a variable and each time the key is pressed, you toggle that boolean state.
Thanks for the reply. Really helped me clear that out.
It certainly seems easier to just let the user customize it, so will just do that :)
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread. MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
voidOnTick()
{
if (IsNewTradingDay() && IsTradingTime())
Your condition is true for one minute. You will open one order per tick that minute.
What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.) "Free-of-Holes" Charts - MQL4 Articles
hellow am new to mql5 and ive been trying to code an indicator where three or morevolume indicatorticks rise or fall consecutively the candles above change colour to green or red and rest grey
.am expiriensing some errors and i would like to know whre am wrong
#property indicator_chart_window#property indicator_buffers6#property indicator_plots1#property indicator_type1DRAW_COLOR_CANDLES#property indicator_color1 Green,Red,Gray
#property indicator_width13#property indicator_label1"Open;High;Low;Close"//--- indicator buffersdouble ExtOBuffer[];
double ExtHBuffer[];
double ExtLBuffer[];
double ExtCBuffer[];
double ExtColorBuffer[];
double ExtVolumesBuffer[];
voidOnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0, ExtOBuffer, INDICATOR_DATA);
SetIndexBuffer(1, ExtHBuffer, INDICATOR_DATA);
SetIndexBuffer(2, ExtLBuffer, INDICATOR_DATA);
SetIndexBuffer(3, ExtCBuffer, INDICATOR_DATA);
SetIndexBuffer(4, ExtVolumesBuffer, INDICATOR_DATA);
SetIndexBuffer(5, ExtColorBuffer, INDICATOR_COLOR_INDEX);
}
intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
if (rates_total < 2)
return (0);
int pos = prev_calculated - 1;
if (pos < 1)
{
ExtVolumesBuffer[0] = 0;
pos = 1;
}
if (ExtVolumesBuffer[0] == 0)
CalculateVolume(pos, rates_total, tick_volume);
else
CalculateVolume(pos, rates_total, volume);
return (rates_total);
}
void CalculateVolume(constint pos, constint rates_total, constlong &volume[])
{
ExtVolumesBuffer[0] = (double)volume[0];
for (int i = pos; i < rates_total && !IsStopped(); i++)
{
ExtOBuffer[i] = open[i];
ExtHBuffer[i] = high[i];
ExtLBuffer[i] = low[i];
ExtCBuffer[i] = close[i];
//--- set color for candle
ExtColorBuffer[i] = 2.0; // set gray Color//--- check for Green Zone and set Color Greenif (ExtVolumesBuffer[i] > ExtVolumesBuffer[i - 1] && ExtVolumesBuffer[i - 1] > ExtVolumesBuffer[i - 2])
ExtColorBuffer[i] = 0.0;
//--- check for Red Zone and set Color Redif (ExtVolumesBuffer[i] < ExtVolumesBuffer[i - 1] && ExtVolumesBuffer[i - 1] < ExtVolumesBuffer[i - 2])
ExtColorBuffer[i] = 1.0;
}
}
//--- indicator settings#property indicator_chart_window#property indicator_buffers6#property indicator_plots1#property indicator_type1DRAW_COLOR_CANDLES#property indicator_color1 Green,Red,Gray
#property indicator_width13#property indicator_label1"Open;High;Low;Close"//--- indicator buffersdouble ExtOBuffer[];
double ExtHBuffer[];
double ExtLBuffer[];
double ExtCBuffer[];
double ExtColorBuffer[];
double ExtVolumesBuffer[];
// Declare ExtVolumesHandle at the global scopeint ExtVolumesHandle;
#define DATA_LIMIT 38//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+voidOnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA);
SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA);
SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA);
SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX);
SetIndexBuffer(5,ExtVolumesBuffer,INDICATOR_DATA);
//---IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- sets first bar from what index will be drawnIndicatorSetString(INDICATOR_SHORTNAME,"Volumes");
//--- don't show indicator data in DataWindowPlotIndexSetInteger(0,PLOT_SHOW_DATA,false);
//--- sets first candle from what index will be drawnPlotIndexSetInteger(0,PLOT_DRAW_BEGIN,DATA_LIMIT);
//--- get handles//--- get handles
ExtVolumesHandle = iVolumes(_Symbol, _Period, VOLUME_TICK);
}
//+------------------------------------------------------------------+//| Trade zone by Bill Williams |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
if(rates_total<DATA_LIMIT)
return(0);
//--- we can copy not all dataint to_copy;
if(prev_calculated>rates_total || prev_calculated<0)
to_copy=rates_total;
else
{
to_copy=rates_total-prev_calculated;
if(prev_calculated>0)
to_copy++;
}
//--- get AO bufferif(IsStopped()) // checking for stop flagreturn(0);
if(CopyBuffer(ExtVolumesHandle,0,0,to_copy,ExtVolumesBuffer)<=0)
{
Print("Getting iVolumes is failed! Error ",GetLastError());
return(0);
}
//--- set first bar from what calculation will startint start;
if(prev_calculated<DATA_LIMIT)
start=DATA_LIMIT;
else
start=prev_calculated-1;
//--- the main loop of calculationsfor(int i=start; i<rates_total && !IsStopped(); i++)
{
ExtOBuffer[i]=open[i];
ExtHBuffer[i]=high[i];
ExtLBuffer[i]=low[i];
ExtCBuffer[i]=close[i];
//--- set color for candle
ExtColorBuffer[i]=2.0; // set gray Color//--- check for Green Zone and set Color Greenif(ExtVolumesBuffer[i]>ExtVolumesBuffer[i-1] && ExtVolumesBuffer[i-1]>ExtVolumesBuffer[i-2])
ExtColorBuffer[i]=0.0;
//--- check for Red Zone and set Color Redif(ExtVolumesBuffer[i]<ExtVolumesBuffer[i-1] && ExtVolumesBuffer[i-1]<ExtVolumesBuffer[i-2])
ExtColorBuffer[i]=1.0;
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+
@law.tout#: Hi All. I am trying to get a very simple EA to place a set of pending long entries either side of current chart symbol price. Can anyone look at the MT4 attached code and tell me why the orders aren't being placed
Please have a look at both the Experts and Journal log and report the error messages that are reported.
Remember that we cannot see your computer nor read your mind, so you need to provide as much relevant information as possible.
No one can help you if you don't explain in detail what is happening on your end.
Hello, I'm a new coder who is learning by myself so this might be a noob question but please bear with me...
What I want to do ===> create a custom indicator that has some hotkeys (for example by pressing Key "A" or "CTRL+A") that will execute a script or some other function.
Question =====> If I use #include Virtualkeys.mqh + WinUser.mqh and use OnChartEvent Keydown + switch case to execute this ( i am using already #defined keys in Virtualkeys.mqh for the case);
1. Will this hotkey work across platforms (windows/MAC OS/Linux)? ( I think Winuser imports user32.dll, not sure if MAC OS supports that)
2. Will this hotkey work across Keyboard layouts/regional settings (US QWERTY/US DVORAK)?
3.If it does not, Is there a way to make it happen? (I've been searching for a way to get a key as a input and set that into the code but haven't still found a way to do that)
4.Also if there is a way to get a key as a user input and use that key for the switch, please enlighten me guys.
Thanks in advance, and my apologies if this is a frequently asked noob question....Hello, I'm a new coder who is learning by myself so this might be a noob question but please bear with me...
What I want to do ===> create a custom indicator that has some hotkeys (for example by pressing Key "A" or "CTRL+A") that will execute a script or some other function.
Question =====> If I use #include Virtualkeys.mqh + WinUser.mqh and use OnChartEvent Keydown + switch case to execute this ( i am using already #defined keys in Virtualkeys.mqh for the case);
1. Will this hotkey work across platforms (windows/MAC OS/Linux)? ( I think Winuser imports user32.dll, not sure if MAC OS supports that)
2. Will this hotkey work across Keyboard layouts/regional settings (US QWERTY/US DVORAK)?
3.If it does not, Is there a way to make it happen? (I've been searching for a way to get a key as a input and set that into the code but haven't still found a way to do that)
4.Also if there is a way to get a key as a user input and use that key for the switch, please enlighten me guys.
Thanks in advance, and my apologies if this is a frequently asked noob question....There is no need to use "user.dll". The OnChartEvent() function can handle keyboard events.
There is no need to use "user.dll". The OnChartEvent() function can handle keyboard events.
Thanks for the reply. Really helped me clear that out.
It certainly seems easier to just let the user customize it, so will just do that :)
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerablf=bugy at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
Your condition is true for one minute. You will open one order per tick that minute.
What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles
return serverHour == TradeHour && serverMinute == TradeMinute;.am expiriensing some errors and i would like to know whre am wrong
Hi All. I am trying to get a very simple EA to place a set of pending long entries either side of current chart symbol price.
Can anyone look at the MT4 attached code and tell me why the orders aren't being placed
TIA
Please have a look at both the Experts and Journal log and report the error messages that are reported.
Remember that we cannot see your computer nor read your mind, so you need to provide as much relevant information as possible.
No one can help you if you don't explain in detail what is happening on your end.
Please have a look at both the Experts and Journal log and report the error messages that are reported.
Remember that we cannot see your computer nor read your mind, so you need to provide as much relevant information as possible.
No one can help you if you don't explain in detail what is happening on your end.
apologies. here is a screenshot from the journal of the tester
You have only shown one of the logs instead of both.
Add more debug prints to your code to print out the parameter values, because error code 3 is ...