This is for different orders. The function of removing one by a condition, removing the other without a condition.
The question is why in my case deletion function works successfully without a condition, but if I put it in a condition, it generates an error when the condition occurs.
The condition must be corrected, you cannot do it without the condition, the logs will take up the whole hard drive
How can it be defined ifticketUP isalready deleted?
You have deleted it, update ticketUP to the state you need, in which the condition to delete the ticketUP will not work, and this condition must be added to the code as well
How can it be defined ifthe ticketUP has already been deleted?
You have deleted it, update ticketUP to the state you need, in which the condition to delete the ticket will not work, and this condition must also be added to the code.
So, the orders withticketD, anotherticketUP are created first (according to the absence condition), and after that they are already deleted.
Take a time-out to "think" at least and figure it out + read what you've been written, what advice you've been given.
By the way, there's freelancing here if it doesn't work...
It's without a condition - because that's how removal occurs, and with a condition - no. So wrote to indicate that I can not. You should write it in this way:
OrderDelete(ticketD);
OrderDelete(ticketUP);
Then every tick deletes orders already created on every tick (according to the absence condition). And if we write it with the condition:
if (x!=maxpr1){x=maxpr1; OrderDelete(ticketD);}
if (z!=minpr1){z=minpr1; OrderDelete(ticketUP);}
Then when the condition occurs, it writes a deletion error.
How do I write the deletion of the specified orders in this condition?
It's without a condition - because that's how deletion works, but with a condition it doesn't. I wrote it this way to point out what I can't do. If you write it in this way:
OrderDelete(ticketD);
OrderDelete(ticketUP);
Then every tick deletes orders already created on every tick (according to the absence condition). And if we write it with the condition:
if (x!=maxpr1){x=maxpr1; OrderDelete(ticketD);}
if (z!=minpr1){z=minpr1; OrderDelete(ticketUP);}
Then when the condition occurs, it writes a deletion error.
How should we write the condition on deleting the specified orders?
You cannot remove the condition to delete orders!
ticketUP and ticketD should be written in the global variables when opening a ticket
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Alternatively, tell me how to write this delete function in this condition.
you must first define the ticket of the pending order to be deleted
if the ticket is null or undefined - then do not delete it
This is for different orders. The function of removing one by a condition, removing the other without a condition.
The question is why in my case deletion function works successfully without a condition, but if I put it in a condition, it generates an error when the condition occurs.
you must first define the ticketD and the ticketUP to be deleted
If the ticket is null or undefined, then no deletion
So defined, one ticketD, the otherticketUP .
Or am I mixing something up?
So defined, one ticketD, the otherticketUP .
Or am I confusing something?
How can it be defined ifticketUP is already deleted?
You have deleted it, update ticketUP to the state you need, in which the condition to delete the ticketUP will not work, and this condition must be added to the code as well
How can it be defined ifthe ticketUP has already been deleted?
You have deleted it, update ticketUP to the state you need, in which the condition to delete the ticket will not work, and this condition must also be added to the code.
So, the orders withticketD, anotherticketUP are created first (according to the absence condition), and after that they are already deleted.
if(BuyLimitCount()==0&& BuyCount()==0){slB=NormalizeDouble(minpr1-pointsl*Point,5);
tpB=NormalizeDouble(minpr1+pointtp*Point,5);
int ticketUP=OrderSend(Symbol(),OP_BUYLIMIT, lotB, minpr1,3, slB, tpB,"", MagicB,0, Red);
if(ticketUP==-1)Print("ERROR OP_BUY"); elsePrint("OP_BUY OK");}
if(SellLimitCount()==0&& SellCount() ==0){
slS=NormalizeDouble(maxpr1+pointsl*Point,5);
tpS=NormalizeDouble(maxpr1-pointtp*Point,5);
int ticketD=OrderSend(Symbol(),OP_SELLLIMIT, lotS, maxpr1,3, slS, tpS,"", MagicS,0, Blue);
if(ticketD==-1)Print("ERROR OP_SELL"); elsePrint("OP_SELL OK");}
if(x!=maxpr1){x=maxpr1;OrderDelete(ticketD);}
OrderDelete(ticketUP);
If I am confused, what?
So orders withticketD, anotherticketUP are created first (according to the absence condition), and then they are deleted.
if(BuyLimitCount()==0&& BuyCount()==0){slB=NormalizeDouble(minpr1-pointsl*Point,5);
tpB=NormalizeDouble(minpr1+pointsl*Point,5);
int ticketUP=OrderSend(Symbol(),OP_BUYLIMIT, lotB, minpr1,3, slB, tpB,"", MagicB,0, Red);
if(ticketUP==-1)Print("ERROR OP_BUY"); elsePrint("OP_BUY OK");}
if(SellLimitCount()==0&& SellCount() ==0){
slS=NormalizeDouble(maxpr1+pointsl*Point,5);
tpS=NormalizeDouble(maxpr1+pointsl*Point,5);
int ticketD=OrderSend(Symbol(),OP_SELLLIMIT, lotS, maxpr1,3, slS, tpS,"", MagicS,0, Blue);
if(ticketD==-1)Print("ERROR OP_SELL"); elsePrint("OP_SELL OK");}
if(x!=maxpr1){x=maxpr1;OrderDelete(ticketD);}
OrderDelete(ticketUP);
If I confuse what?
Again you have a command without a condition:
OrderDelete(ticketUP);
Why didn't you change the code?
Take a time-out to "think" at least and sort it out + read what you've written, what advice was given.
By the way, there's freelancing here, if you can't...
So again you have a command without a condition:
OrderDelete(ticketUP);
Why didn't you change the code?
Take a time-out to "think" at least and figure it out + read what you've been written, what advice you've been given.
By the way, there's freelancing here if it doesn't work...
It's without a condition - because that's how removal occurs, and with a condition - no. So wrote to indicate that I can not. You should write it in this way:
OrderDelete(ticketD);
OrderDelete(ticketUP);
Then every tick deletes orders already created on every tick (according to the absence condition). And if we write it with the condition:
if (x!=maxpr1){x=maxpr1; OrderDelete(ticketD);}
if (z!=minpr1){z=minpr1; OrderDelete(ticketUP);}
Then when the condition occurs, it writes a deletion error.
How do I write the deletion of the specified orders in this condition?
It's without a condition - because that's how deletion works, but with a condition it doesn't. I wrote it this way to point out what I can't do. If you write it in this way:
OrderDelete(ticketD);
OrderDelete(ticketUP);
Then every tick deletes orders already created on every tick (according to the absence condition). And if we write it with the condition:
if (x!=maxpr1){x=maxpr1; OrderDelete(ticketD);}
if (z!=minpr1){z=minpr1; OrderDelete(ticketUP);}
Then when the condition occurs, it writes a deletion error.
How should we write the condition on deleting the specified orders?
You cannot remove the condition to delete orders!
ticketUP and ticketD should be written in the global variables when opening a ticket
GlobalVariableSet("ticketUP",ticketUP);
GlobalVariableSet("ticketD",ticketD);
and read from there before deleting a pending ticket
ticketUP=GlobalVariableGet("ticketUP")
ticketD=GlobalVariableGet("ticketD")
By the way, look there (in global) - what you have, what ticket is written
I think, that after that all will work as it should
{
private:
template <typename T>
T _array[];
int _index;
int _err;
int _err_sys;
public:
CArray(){_index = -1; _err = 0; _err_sys = 0;}
~CArray(){}
// template <typename T>
T operator[](int i){
if((_index == -1) || (i < 0) || (i > _index)) {_err_sys = -1;}
return (_array[i]);
}
T at(int i){
if((_index == -1) || (i < 0) || (i > _index)) {_err_sys = -1;}
return (_array[i]);
}
void push_back(T value){
_array[++_index] = value;
}
};
part of the program code:
#property link "https://www.mql5.com"
#property version "1.1"
#property strict
#include "Array.mqh"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
CArray *array;
int OnInit()
{
int b = 1;
array = new CArray();
array.push_back(b);
int a = array.at(0);
//---
return(INIT_SUCCEEDED);
}
...
After trying to run the Expert Advisor on real data, the following error is thrown: internal error #-1005
What I do wrong? Thanks in advance!