MetaTrader 4 Client Terminal build 610 - page 24

 
TJmclovin:

Is there a plan to add the function

as it exists in MQL5?

It is even referenced in the example at https://docs.mql4.com/chart_operations/chartsavetemplate but seems to be not implemented yet.. :(

Not planned.
 
More interesting behaviour of datetime functions.
Although both OrderOpenTime() and TimeCurrent() are datetime types.
One gets commented as seconds and the other in date time format..
with the strict property disabled they both display in seconds.
 
Jimdandy:
More interesting behaviour of datetime functions.
Although both OrderOpenTime() and TimeCurrent() are datetime types.
One gets commented as seconds and the other in date time format..
with the strict property disabled they both display in seconds.


Why not use TimeToString?
 
Jimdandy:
More interesting behaviour of datetime functions.
Although both OrderOpenTime() and TimeCurrent() are datetime types.
One gets commented as seconds and the other in date time format..
with the strict property disabled they both display in seconds.


The OrderOpenTime displays int type rather than datetime in the Metaeditor. So discrepancy, you may ask for a fix.

 
Ovo: The OrderOpenTime displays int type rather than datetime in the Metaeditor. So discrepancy, you may ask for a fix.
There's a lot of examples in the docs. Like iMA taking int arguments instead of ENUM_TIMEFRAMES, ENUM_MA_METHOD, and ENUM_APPLIED_PRICE.
 
WHRoeder:
There's a lot of examples in the docs. Like iMA taking int arguments instead of ENUM_TIMEFRAMES, ENUM_MA_METHOD, and ENUM_APPLIED_PRICE.

Yes, it is too early yet to report every glitch.
 

I thought int arguments were an acceptable alternative, I have always used int arguments instead of MODE_EMA etc. Also in functions like SetIndexStyle(). In the docs it usually gives the int value along side the formal identifier.

 
SDC:

I thought int arguments were an acceptable alternative, I have always used int arguments instead of MODE_EMA etc. Also in fucntions like SetIndexStyle(). In the docs it usually gives the int along side the formal identifier.


Yes, they are, but the word is about discrepancy between help and editor/compiler.
 

Oh I see ... yes that could cause confusion.

 

I have found what seems to be an undocumented feature and was hoping some one could help me fix it.

I have an EA which I have been developing for quite some time now and found unusual behavior when I added a new feature to size the chat based on historical bars. I simply get the highest high in the last x bars and the lowest low then set the chart to size this range. I have recreated an example and will post the code below. My problem is when the chart is in focus everything seems to work as planned. But when the chart in not in focus it behaves strangely, if you switch the focus to the chart it seems to be condensed at the top of the chart, then corrects on the next cycle. I don't think it is a show stopper but I found it confusing. If anyone could shed some light as to how to avoid this behaviour I would happy. I hope I have explained my problem well enough for some help.

//+------------------------------------------------------------------+
//| Charting01.mq4 |
//| Copyright 2014, MyBabyBot.com |
//| http://mybabybot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MyBabyBot.com"
#property link "http://mybabybot.com"
#property version "1.00"
#property strict

input int LimitAveBars = 20000; //---- Number of bars to average for highs and lows
input int AveBarsMean = 10000; //---- Number of bars to average for second level highs and lows
input double LowPercent = 25; //---- Percentage of high to low range that should limit order open direction
input double HighPercent = 25; //---- Percentage of high to low range that should limit order open direction

double Averages[6]; // Will hold high low and 25% &75% values over given number of bars

// --- Internal working variables
int LimitAveBars1;
double dif;
double diff;
// --- End internal variables

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
MakeObjects();

ChartSetInteger(0, CHART_SHOW_ASK_LINE, true);
ChartSetInteger(0, CHART_SHOW_BID_LINE, true);
ChartSetInteger(0, CHART_SHIFT, true);
ChartSetInteger(0, CHART_AUTOSCROLL, true);
ChartSetInteger(0, CHART_DRAG_TRADE_LEVELS, false);
ChartSetInteger(0, CHART_SHOW_OHLC, false);
ChartSetDouble(0, CHART_FIXED_POSITION, true);
ChartSetDouble(0, CHART_SHIFT_SIZE, 10);
ChartSetInteger(0, CHART_SCALEFIX, true);
return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
ObjectsDeleteAll(); // --- Clean up after ourselves
}

//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
CalcAverages(); // ---- Calculate the verages for highs and lows

ChartSetDouble(0, CHART_FIXED_MAX,Averages[3]+ Averages[3] * .002); // Testing for chart size
ChartSetDouble(0, CHART_FIXED_MIN,Averages[0]-Averages[0]* .002); // Testing for chart size
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Calculate the highs, lows and averages |
//+------------------------------------------------------------------+
void CalcAverages()
{
if(LimitAveBars>LimitAveBars1) LimitAveBars1=LimitAveBars;
if(LimitAveBars1>Bars) LimitAveBars1=Bars-1;

Averages[3]=High[iHighest(NULL,0,MODE_HIGH,LimitAveBars1,0)]; // High over period
Averages[0]=Low[iLowest(NULL,0,MODE_LOW,LimitAveBars1,0)]; // Low over period
Averages[5]=High[iHighest(NULL,0,MODE_HIGH,AveBarsMean,0)]; // High over Second level period
Averages[4]=Low[iLowest(NULL,0,MODE_LOW,AveBarsMean,0)]; // High over Second level period
dif=Averages[3]-Averages[0]; // Calc difference between high and low averages
Averages[1]=Averages[0]+(dif*LowPercent/100); // Low percent over period
Averages[2]=Averages[3]-(dif*HighPercent/100); // High Percent over period

ObjectSet("ChartHigh", OBJPROP_PRICE1, Averages[3]); //---- Position line on chart
ObjectSet("ChartHighPercent", OBJPROP_PRICE1, Averages[2]); //---- Position line on chart
ObjectSet("ChartLowPercent", OBJPROP_PRICE1, Averages[1]); //---- Position line on chart
ObjectSet("ChartLow", OBJPROP_PRICE1, Averages[0]); //---- Position line on chart
ObjectSet("ChartLowMean", OBJPROP_PRICE1, Averages[4]); //---- Position line on chart
ObjectSet("ChartHighMean", OBJPROP_PRICE1, Averages[5]); //---- Position line on chart

diff=dif *10000; // Correct the difference for points 4 digit
if(Digits==5) diff=dif*100000; // Correct the difference for points 5 digit
ObjectSetText("Ranges","Range = "+DoubleToStr(diff,0),10,"Times New Roman",Yellow); // Display the range at the top of the chart
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Make objects function |
//+------------------------------------------------------------------+
void MakeObjects()
{
if(!ObjectCreate("ChartHigh",OBJ_HLINE,0,Time[0],0))
{
Print("error: can't ChartHigh! code #",GetLastError());
}
ObjectSet("ChartHigh",OBJPROP_COLOR,Yellow);

if(!ObjectCreate("ChartHighPercent",OBJ_HLINE,0,Time[0],0))
{
Print("error: can't create ChartHighPercent! code #",GetLastError());
}
ObjectSet("ChartHighPercent",OBJPROP_COLOR,Gold);
ObjectSet("ChartHighPercent",OBJPROP_WIDTH,3);

if(!ObjectCreate("ChartLow",OBJ_HLINE,0,Time[0],0))
{
Print("error: can't create ChartLow! code #",GetLastError());
}
ObjectSet("ChartLow",OBJPROP_COLOR,Blue);

if(!ObjectCreate("ChartLowPercent",OBJ_HLINE,0,Time[0],0))
{
Print("error: can't create ChartLowPercent! code #",GetLastError());
}
ObjectSet("ChartLowPercent",OBJPROP_COLOR,Aqua);
ObjectSet("ChartLowPercent",OBJPROP_WIDTH,3);

if(!ObjectCreate("ChartLowMean",OBJ_HLINE,0,Time[0],0))
{
Print("error: can't create ChartLowMean! code #",GetLastError());
}
ObjectSet("ChartLowMean",OBJPROP_COLOR,Crimson);
ObjectSet("ChartLowMean",OBJPROP_STYLE,STYLE_DOT);

if(!ObjectCreate("ChartHighMean",OBJ_HLINE,0,Time[0],0))
{
Print("error: can't create ChartHighMean! code #",GetLastError());
}
ObjectSet("ChartHighMean",OBJPROP_COLOR,Crimson);
ObjectSet("ChartHighMean",OBJPROP_STYLE,STYLE_DOT);

if(!ObjectCreate("Ranges",OBJ_LABEL,0,0,0))
{
Print("error: can't create label_object! code #",GetLastError());
}
ObjectSet("Ranges",OBJPROP_YDISTANCE,10);
ObjectSet("Ranges",OBJPROP_XDISTANCE,570);
}
//+------------------------------------------------------------------+


Reason: