Questions from Beginners MQL5 MT5 MetaTrader 5 - page 97
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
The idea is yours, but not the code. The programmer wrote the code, not you, you wrote the ToR.
Imagine - Windows users demanding open source - isn't that absurd?
As far as I understand, the code used by the experts belongs to MetaQuotes, or to you personally?
What does this have to do with Windows, firstly users do not have the right to demand it because this product belongs to macrosoft, here is a little different, macrosoft will start asking for open source code of their product from programmers who wrote it, and they will twist their fingers and not give it.
Aah :-=) so there are sources before protection? what else do you want then? You have been told - no one will give open source code of protected EA, and I would not give it. And if there was a requirementto demand the source code of your product after completion.
I would have refused the task.
What else do you need then? There is the source code before the defence, so it is the same as the advisor with the defence. they should work equally well.
In the process of the Expert Advisor's work, modifications were made, various functions were added, etc., but there is no open source code with these modifications.
then I think the truth is on your side.
As far as I understand, the code used by the experts belongs to MetaQuotes, or to you personally?
If I write the code, it belongs to me personally.MetaQuotes owns the programming language.
everything is fair.
Can you tell me how to close an open order in Expert Advisor? I understand how a position is closed at Stop Loss or Take Profit. How to do it manually?
Could you please advise how to close an open order in an Expert Advisor? I understand how a position is closed at Stop Loss or Take Profit. How to do it manually?
Or use the CTrade class, which has a function
trade.PositionClose(_Symbol);
something like this
https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade/ctradepositionclose
lazarev-d-m: Or use the CTrade class, there is a function
The PositionClose() method of the CTrade class also closes a position using opposite orders.
Please advise me on the solution or reason for this situation. I am working in MQL5 not so long ago, so I do not have enough experience yet.
I have tried to make a multi-currency EA without using classes. Unfortunately, I haven't found any detailed article on multicurrency EAs.
I wrote the following piece of code.
int nomer_instr; // this is the index number of currency in the array of currency names
string Name_symbol[6] = { "AUDUSD", "EURUSD", "GBPUSD", "USDCAD", "USDCHF", "USDJPY" } ; // text array of currency names: in [0]-"AUDUSD", 1-"EURUSD", 2-"GBPUSD", 3-"USDCAD", etc.
double Close_buf[], Open_buf[], High_buf[], Low_buf[]; //base arrays for candlestick parameters
datetime Time_buf[]; //base array of bar open time
double Close_H1[6][150], Open_H1[6][150], High_H1[6][150], Low_H1[6][150]; // arrays for parameters of multi-currency EA candlesticks for H1 timeframe
// the number of rows in the array corresponds to the number of analyzed currencies
datetime Time_H1[6][150]; // array of bar open time
double Close_H4[6][150], Open_H4[6][150], High_H4[6][150], Low_H4[6][150]; // arrays for parameters of candlesticks of the multicurrency Expert Advisor for H4 timeframe
// the number of rows in the array corresponds to the number of currencies analysed
datetime Time_H4[6][150]; // array bar open time
int OnInit()
{
}
void OnDeinit(const int reason)
{
//---
ArrayFree(Time_buf);
ArrayFree(Close_buf);
ArrayFree(Open_buf);
ArrayFree(High_buf);
ArrayFree(Low_buf);
}
void OnTick()
{
//------------------------------------------------------------------------------
here is a piece of code for determining the moment when a new bar opens Nev_Time[0]
and the serial number of the bar being processed in the process of testing or trading
//------------------------------------------------------------------------------------------------------------------------
ArraySetAsSeries(Close_buf, true); //set indexing for the close_array array as in timeseries
ArraySetAsSeries(Open_buf, true); //set indexing for array open_array as in timeseries
ArraySetAsSeries(High_buf, true); //set indexing for array high_array as in timeseries
ArraySetAsSeries(Low_buf, true); //set indexing for array low_array as in timeseries
ArraySetAsSeries(Time_buf, true); //set indexing for array time_array as in timeseries
for( nomer_instr=0; nomer_instr<=5; nomer_instr++ )
{
//========================================================================
CopyTime( Name_symbol[nomer_instr], PERIOD_H1,0,160,Time_buf); // copy historical time data for each bar to buffer
CopyClose( Name_symbol[nomer_instr], PERIOD_H1,0,160,Close_buf); // copy historical data close for each bar to the buffer
CopyOpen( Name_symbol[nomer_instr], PERIOD_H1,0,160,Open_buf); // copy history data open for each bar to the buffer
CopyHigh( Name_symbol[nomer_instr], PERIOD_H1,0,160,high_buf); // copy history data high for each bar to the buffer
CopyLow( Name_symbol[nomer_instr], PERIOD_H1,0,160,low_buf); // copy historical data low for each bar to the buffer
//========================================================================
for( i=1; i<=145; i++ )
{
Time_H1[nomer_instr][i]=Time_buf[i];
Close_H1[nomer_instr][i]=Close_buf[i];
Open_H1[nomer_instr][i]=Open_buf[i];
High_H1[nomer_instr][i]=High_buf[i];
Low_H1[nomer_instr][i]=Low_buf[i];
}
//======================================================================================
// check the time shift of the generated candlestick data of an hour timeframe
if( Schetchik_svech > 8 && Schetchik_svech < 15 )
{
if( nomer_instr == 5 )
{
Alert("================================================");
Alert(" bar number = ",Schetchik_svech,", bar open time Nev_Time[0]=",Nev_Time[0]);
Alert(" instrument number: nomer_instr=",nomer_instr,", instrument: Name_symbol[nomer_instr]=",Name_symbol[nomer_instr]);
Alert("---------------------------------------------------------");
for(( i=1; i<=5; i++ )
{
Alert("i=",i,", Time_H1[nomer_instr][i]=",Time_H1[nomer_instr][i],", Close_H1[nomer_instr][i]=",Close_H1[nomer_instr][i]);
}
}
}
//======================================================================================
} // end of loop for the used currencies on H1 timeframe
//##############################################
here is the same piece of the chart for the H4 timeframe
//############################################
} // end of the OnTick() function
Checking the performance of this piece of software revealed to me an unexpected result:
- For the case of H1, when the output of the parameters of bars for the chart, on which the Expert Advisor stands, we have a one hour time difference between the opening of zero bar and the first bar.
For example, the Expert Advisor is on the EURUSD chart and the time of the zero bar opening is Nev_Time[0]=2011.01.03 13:00:00, then the time of the opening of the first bar Time_H1[1][1]=2011.01.03 12:00:00
The result is consistent with common sense.
- Now the Expert Advisor is on the same chart and we analyse the data of any other currency, e.g. AUDUSD:
time of the zero bar opening Nev_Time[0]=2011.01.03 13:00:00, then the opening time of the 1st bar Time_H1[1][1]=2011.01.03 11:00:00
This result is simply unacceptable, but I haven't found any reasons for this effect in the articles.
Please advise how to get rid of this nuisance, I can't write an Expert Advisor for each currency.
Thank you for your feedback.
What does Time_H1[1][0] return?
I do not use this element of the array, because I will go straight to the algorithm for searching fractals on the last 5 bars. And Time_H1[1][0] is the open time of the zero bar where parameters of this bar have not been formed yet. I may be wrong, but from my own experience, I know that using parameters of a zero bar to form timeseries leads to their distortion.