Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - 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
Good afternoon, gentlemen!)
Trying to prepare data for training a neural network. The task is.
Have a matrix, where for example each row (time moment - bar) is an input vector, and columns for example 10000. What to do if there is dynamic data (number of rows1, rows2), and change in number at different points in time.
For example, a matrix is loaded into a network, each row is a vector for learning, but for each row, there is n number of rows dynamically changing in time.
A possible solution conjecture is to add additional columns to the matrix equal to the number of columns in the dynamical row, it turns out that each vector will have columns from the denamic, but as if of one row, just prosumed.
for example
1st vector
1.365 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 ... "line1 dynamic" 1 1 1 1 1
ssssssssssssssssssssssssssssssssss "line2 dynamic" 1 1 1 1
solution
1.365 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 ... "line1 dynamic" 2 2 2 2 2
Good afternoon, gentlemen!)
Trying to prepare data for training a neural network. The task is.
Have a matrix, where for example each row (time moment - bar) is an input vector, and columns for example 10000. What to do if there is dynamic data (number of rows1, rows2), and change in number at different points in time.
For example, a matrix is loaded into a network, each row is a vector for learning, but for each row, there is n number of rows dynamically changing in time.
A possible solution conjecture is to add additional columns to the matrix equal to the number of columns in the dynamical row, it turns out that each vector will have columns from the denamic, but as if of one row, just prosumed.
for example
1st vector
1.365 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 ... "line1 dynamic" 1 1 1 1 1
ssssssssssssssssssssssssssssssssss "line2 dynamic" 1 1 1 1
solution
1.365 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 ... "line1 dynamic" 2 2 2 2 2
https://www.mql5.com/ru/articles/159
So there's MQL5, as I understand it. Or is it identical?
Good afternoon. I have created an EA, it works fine, but if I turn off the terminal with the EA running and turn the terminal back on, the EA starts counting all over again. So, I have a question. What do I need to prescribe in the EA, so it would reset the Input parameters when it starts?
Good afternoon. I have created an EA, it works fine, but if I turn off the terminal with the EA running and turn the terminal back on, the EA starts counting all over again. So, I have a question. What do I need to write in my EA, so it would reset the Input parameters when I start it?
Greetings. Can you tell me what is wrong?
The EA places orders with stops above and below the price. If one of them triggers, the stop is adjusted if the price moves away from the stop more than set, if the price moves to the stop then no change.
At first I have written only Buy order and it has worked as expected. If I add a mirror image for sell, the stops will be corrected by the set value whatever the price moves.
In general, if separately, or to buy or to sell - everything works as it should, but both parts together - there is a bug.
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern double Lot = 0.01;
extern int StopLoss = 50;
extern int Slippage = 5;
extern int Delta = 60;
extern int Delta2 = 170;
extern int Magic = 321;
int ticket;
double price, sl, sl2;
datetime counted_bar = 0;
int OnInit()
{
if (Digits == 3 || Digits == 5)
{
StopLoss *= 10;
Delta *= 10;
Delta2 *= 10;
}
return(INIT_SUCCEEDED);
}
void OnTick() {
////// ПРОДАЖА ///////////////////////////////////////////////////////
if (SellLimitCount()==0 && SellCount()==0)
{
price = NormalizeDouble(Bid - Delta*Point, Digits);
sl = NormalizeDouble(price + StopLoss*Point, Digits);
ticket = OrderSend (Symbol(), OP_SELLSTOP, Lot, price, Slippage, sl, 0, "", Magic, 0, Red);
}
if (SellCount()!=0)
{
if (Bid < (OrderStopLoss() - NormalizeDouble (StopLoss*Point, Digits)))
{
sl = NormalizeDouble (Bid + StopLoss*Point, Digits);
if (OrderModify(ticket, price, sl, 0, 0, Red)) Print ("Sell_Order_Modify_Ok");
else Print ("ERROR_Sell_Order_Modify");
}
}
if (SellLimitCount()!=0)
{
if(Bid > (OrderOpenPrice() + NormalizeDouble (Delta2*Point, Digits)))
{
if (OrderDelete(ticket, Red)) Print ("BuyLimit_Order_Delete_Ok");
else Print ("ERROR_BuyLimit_Odrer_Delete");
}
}
/////////////////////////////////////////////////////////////////////////////////
/////// ПОКУПКА ////////////////////////////////////////////////////////
if (BuyLimitCount()==0 && BuyCount()==0)
{
price = NormalizeDouble(Ask + Delta*Point, Digits);
sl = NormalizeDouble(price - StopLoss*Point, Digits);
ticket = OrderSend (Symbol(), OP_BUYSTOP, Lot, price, Slippage, sl, 0, "", Magic, 0, Blue);
}
if (BuyCount()!=0)
{
if (Ask > (OrderStopLoss() + NormalizeDouble (StopLoss*Point, Digits)))
{
sl = NormalizeDouble (Ask - StopLoss*Point, Digits);
if (OrderModify(ticket, price, sl, 0, 0, Blue)) Print ("Buy_Order_Modify_Ok");
else Print ("ERROR_Buy_Order_Modify");
}
}
if (BuyLimitCount()!=0)
{
if(Ask < (OrderOpenPrice() - NormalizeDouble (Delta2*Point, Digits)))
{
if (OrderDelete(ticket, Blue)) Print ("BuyLimit_Order_Delete_Ok");
else Print ("ERROR_BuyLimit_Orde_Delete");
}
}
///////////////////////////////////////////////////////////////////////////////
}
//+------------------------------------------------------------------+
int BuyLimitCount(){
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
if(OrderMagicNumber()==Magic){
if(OrderType()==OP_BUYSTOP)
count++;}}}return(count);}
int BuyCount(){
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
if(OrderMagicNumber()==Magic){
if(OrderType()==OP_BUY)
count++;}}}return(count);}
int SellLimitCount(){
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
if(OrderMagicNumber()==Magic){
if(OrderType()==OP_SELLSTOP)
count++;}}}return(count);}
int SellCount(){
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
if(OrderMagicNumber()==Magic){
if(OrderType()==OP_SELL)
count++;}}}return(count);}
Greetings. Can you tell me what is wrong?
The EA places orders with stops above and below the price. If one of them triggers, the stop is adjusted if the price moves away from the stop more than set, if the price moves to the stop then no change.
At first I have written only Buy order and it has worked as expected. If I add a mirror image for sell, the stops will be corrected by the set value whatever the price moves.
Generally, if separately, or to buy or to sell, everything is working as it should be, but both parts together - there is a bug.
The entire code you have shown us is a bug, isn't it? At least, the OnTick function is almost entirely a bug...
A bug, do you mean the whole code shown?