Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 490
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon!
I have an EA that does certain calculations. It uses different math operations, arrays, loops. It saves the result to a file. It has to start everything from the beginning after it has performed all the actions. It has done all the calculations once and then hangs for the second time without taking any action. Can you advise whether it is necessary to zero variables, clear arrays or something else before starting a new calculation?
Have you tried closing the file?
How to program a crutch/indicator/script (as an indicator with tabs "about program, General, Input parameters, Colors, Display") for MT4 so that it would take the data from a .csv file, for example the format ofthe source file:
I.e.the indicator took the recorded data from a file and put itas a line segment (TF, TA) or a colored band(EA) with the parameters of the extent equal to "one day". (from the border to the border of the vertical separators of days on МТ4), for lines selection of the line colour, line type, selection of the text colour and comment size and substitution of the comment line as "TF - 1,192" the second line "TF - 1,1733" which are taken from the corresponding lines of the file. The range is purely horizontal and from the line EUR;TF;1.192;1,1733 it takes the first digit for one slot and the second digit for the second one as the start of slot 1.192 and the end of slot 1.192.
There are also ranges, for example EA, the principle is the same from the beginning to the end of the day but the price is different and the line begins and ends with CHF;AB1;1.03484132734247;1.02549513556164 beginning is1.03484132734247 end of the range1.02549513556164. Runs when you turn on MT4 (as a normal indicator on the gafik), every day on the chart and adds all the data exactly for the current day once, all the lines applied earlier is not removed from the chart and does not duplicate. With all this it selects and displays all of the segments and ranges for the day, only where the active window is now and in other active windows (i.e., where it is running) (i.e., it opened a pair and the indicator drew all of the segments and ranges of the current day and calmed down and so on for the pairs).
For example, how should look the tab of indicatorInput parameters:
tried to scribble myself, but do not get a damn thing although seemed easy (but I am a humanitarian, what can you do....) Help please drowning !!!!!!!!
Hello!
Please help me find a bug in the following program!!!
//+------------------------------------------------------------------+
//|test.mq4 |
//| Copyright 2018, MetaQuotes Software Corp.
//|https://www.mql5.com ||
//+------------------------------------------------------------------+
#property copyright "365_MA"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern Period_MA = 365; //Period MA 1
extern double Delta = 0.0010; //The distance at which the order can be opened
string Symb; //Name of the trade instrument
//int Total; //number of orders
//+------------------------------------------------------------------+
//| expert initialization function|
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function|
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("Obj_Label");
ObjectDelete("Obj_Label2");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function|
//+------------------------------------------------------------------+
int start()
{
double prise = Bid;//current price
double CurrMAValue = iMA(Symb, Period(),Period_MA, 0,Mode_EMA, PRICE_CLOSE, 0); //the value of Moving Average
double Price2MA = price - CurrMAValue;//distance between MA and price
datetime NextClose = Time(0) + Period()*60*2;//time to close
int MinutesToNextClose = (NextClose - TimeCurrent())/60 + 1; //time to close in minutes
//int err;
//refresh text information on the chart
ObjectSetText ("Obj_Label", "TF" + Period() + ", " + DoubleToStr(price, 4) + ", tick " + TimeToStr(TimeCurrent(), TIME_SECONDS) + ", O@" + TimeToStr(Time[0], TIME_MINUTES) + ", NC@" + TimeToStr(NextClose, TIME_MINUTES) + " (" + MinutesToNextClose + " min)", 10,
ObjectSetText ("Obj_Label2", "Delta " + DoubleToStr(Delta,4) + ", MA value " + DoubleToStr(CurrMAValue, 4) + ", distance to MA " + DoubleToStr(Price2MA, 4), 10, "Arial", DarkGreen );
//consider price and generate alerts
if ((MathAbs(Price2MA) < Delta) && // if the distance to МА is less than delta
(Price > CurrMAValue) && // and the price is higher than MA
(Open(0) > CurrMAValue+Delta) // and the current candle opened higher than MA+Delta
(
Alert ("Price is approaching to the MA from above;)
)
if ((MathAbs(Price2MA) < Delta) && // if the distance to the MA is less than the delta
(price < CurrMAValue) && // and the price is below the MA
(Open(0) < CurrMAValue-Delta)) // and the current candle opened below the MA delta
(
Alert ("Price approached below the MA;)
)
return(0);
//+------------------------------------------------------------------+
After compiling the following error
Hello!
Please help me find a bug in the following program!!!
After compiling the following error.
A curly bracket has been left out.
I need to integrate zigzag into my own indicator (now it's counting by handle)
The thing is, my indicator does not use OnCalculate().
So how do I make the zigzag work and how do I get rates_total and prev_calculated?
The rates_total is the number of bars on the chart. It is determined using the Bars function.
prev_calculated - create an analogue on your own, declare it globally (or statically) and write there the actually calculated number of bars in the current iteration. It means, after successful calculations of the indicator values, we need to record the number of current bars in it. If the calculations are unsuccessful, it's better to null it in order to recalculate the indicator values for each bar in the history at the next iteration.
Re: Alekseu Fedotov
What is a brace, sorry
Re: Alekseu Fedotov
What is a brace, sorry
In square brackets, the index of array x[25].
void start()
{
In curly braces operator block
}
In parentheses the argument of the function sin(30)
in square brackets the index of array x[25]
void start()
{
In curly braces operator block
}