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
Hello!
To fix the indicator, you had to replace all the dots "." with a blank "".
Greetings.
I changed theorder selection type in the written function of certain order counting from selection by order to selection by ticket.
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUYLIMIT)
count++;}}}return(count);}
int count=0;
if(OrderSelect(ticketUP, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUYLIMIT)
count++;}}return(count);}
After that, when running a few dozen candles, everything works correctly and after that there are repeated errors in the log:
2016.12.17 17:44:31.609 2016.12.07 00:27 test3 EURUSD,M1: unknown ticket 2 for OrderModify function
2016.12.17 17:44:31.608 2016.12.07 00:25 test3 EURUSD,M1: OrderModify error 4108 // Invalid ticket number.
Here is the full text, I changed it in all four functions:
double slB, tpB, slS, tpS; double x=0, z=0; int ticketUP, ticketD;
void OnTick()
{
double maxpr1=-9999; double minpr1=9999;
for(int shift1=0; shift1<bars; shift1++)
{double i=iHigh(Symbol(), PERIOD_CURRENT, shift1);
if (i>maxpr1){maxpr1=i;}}
for(int shiftA1=0; shiftA1<bars; shiftA1++)
{double y=iLow(Symbol(), PERIOD_CURRENT, shiftA1);
if (y<minpr1) {minpr1=y;}}
if (BuyLimitCount()==0 && BuyCount()==0){
slB=NormalizeDouble(minpr1-pointsl*Point,5);
tpB=NormalizeDouble(minpr1+pointtp*Point,5);
ticketUP=OrderSend(Symbol(), OP_BUYLIMIT, lotB, minpr1, 3, slB, tpB, "", MagicB, 0, Red);
if (ticketUP==-1) Print("ERROR OP_BUY"); else Print("OP_BUY OK");}
if (SellLimitCount()==0 && SellCount() ==0){
slS=NormalizeDouble(maxpr1+pointsl*Point,5);
tpS=NormalizeDouble(maxpr1-pointtp*Point,5);
ticketD=OrderSend(Symbol(), OP_SELLLIMIT, lotS, maxpr1, 3, slS, tpS, "", MagicS, 0, Blue);
if (ticketD==-1) Print("ERROR OP_SELL"); else Print("OP_SELL OK");}
if (x!=maxpr1){x=maxpr1;
slS=NormalizeDouble(maxpr1+pointsl*Point,5);
tpS=NormalizeDouble(maxpr1-pointtp*Point,5);
OrderModify(ticketD, maxpr1, slS, tpS, 0, Blue);}
if (z!=minpr1){z=minpr1;
slB=NormalizeDouble(minpr1-pointsl*Point,5);
tpB=NormalizeDouble(minpr1+pointtp*Point,5);
OrderModify(ticketUP, minpr1, slB, tpB, 0, Red);}
double maxpr=-9999; double minpr=9999;
for(int shift=0; shift<bars; shift++)
{double e=iHigh(Symbol(), PERIOD_CURRENT, shift);
if (e>maxpr){maxpr=e;}}
for(int shiftA=0; shiftA<bars; shiftA++)
{double r=iLow(Symbol(), PERIOD_CURRENT, shiftA);
if (r<minpr) {minpr=r;}}
string a;
if(bars==1)a="bar: ";
else a= IntegerToString(bars,1) + " bar's: ";
Comment("Last ", a, "max ", DoubleToStr(maxpr, 5), ", min ", DoubleToStr(minpr, 5),".");
}
int BuyLimitCount(){
int count=0;
if(OrderSelect(ticketUP, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUYLIMIT)
count++;}}return(count);}
int BuyCount(){
int count=0;
if(OrderSelect(ticketUP, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUY)
count++;}}return(count);}
int SellLimitCount(){
int count=0;
if(OrderSelect(ticketD, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicS){
if(OrderType()==OP_SELLLIMIT)
count++;}}return(count);}
int SellCount(){
int count=0;
if(OrderSelect(ticketD, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicS){
if(OrderType()==OP_SELL)
count++;}}return(count);}
And here there is one moment - after I changed the selection function, the order modify function started to generate an error and only after some time oftesting, at first everything was normal.
Why does this happen and how to deal with it?
Greetings.
I changed theorder selection type in the written function of certain order counting from selection by order to selection by ticket.
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--){
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUYLIMIT)
count++;}}}return(count);}
int count=0;
if(OrderSelect(ticketUP, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUYLIMIT)
count++;}}return(count);}
After that, when running a few dozen candles, everything works correctly and after that there are repeated errors in the log:
2016.12.17 17:44:31.609 2016.12.07 00:27 test3 EURUSD,M1: unknown ticket 2 for OrderModify function
2016.12.17 17:44:31.608 2016.12.07 00:25 test3 EURUSD,M1: OrderModify error 4108 // Invalid ticket number.
Here is the full text, I changed it in all four functions:
double slB, tpB, slS, tpS; double x=0, z=0; int ticketUP, ticketD;
void OnTick()
{
double maxpr1=-9999; double minpr1=9999;
for(int shift1=0; shift1<bars; shift1++)
{double i=iHigh(Symbol(), PERIOD_CURRENT, shift1);
if (i>maxpr1){maxpr1=i;}}
for(int shiftA1=0; shiftA1<bars; shiftA1++)
{double y=iLow(Symbol(), PERIOD_CURRENT, shiftA1);
if (y<minpr1) {minpr1=y;}}
if (BuyLimitCount()==0 && BuyCount()==0){
slB=NormalizeDouble(minpr1-pointsl*Point,5);
tpB=NormalizeDouble(minpr1+pointtp*Point,5);
ticketUP=OrderSend(Symbol(), OP_BUYLIMIT, lotB, minpr1, 3, slB, tpB, "", MagicB, 0, Red);
if (ticketUP==-1) Print("ERROR OP_BUY"); else Print("OP_BUY OK");}
if (SellLimitCount()==0 && SellCount() ==0){
slS=NormalizeDouble(maxpr1+pointsl*Point,5);
tpS=NormalizeDouble(maxpr1-pointtp*Point,5);
ticketD=OrderSend(Symbol(), OP_SELLLIMIT, lotS, maxpr1, 3, slS, tpS, "", MagicS, 0, Blue);
if (ticketD==-1) Print("ERROR OP_SELL"); else Print("OP_SELL OK");}
if (x!=maxpr1){x=maxpr1;
slS=NormalizeDouble(maxpr1+pointsl*Point,5);
tpS=NormalizeDouble(maxpr1-pointtp*Point,5);
OrderModify(ticketD, maxpr1, slS, tpS, 0, Blue);}
if (z!=minpr1){z=minpr1;
slB=NormalizeDouble(minpr1-pointsl*Point,5);
tpB=NormalizeDouble(minpr1+pointtp*Point,5);
OrderModify(ticketUP, minpr1, slB, tpB, 0, Red);}
double maxpr=-9999; double minpr=9999;
for(int shift=0; shift<bars; shift++)
{double e=iHigh(Symbol(), PERIOD_CURRENT, shift);
if (e>maxpr){maxpr=e;}}
for(int shiftA=0; shiftA<bars; shiftA++)
{double r=iLow(Symbol(), PERIOD_CURRENT, shiftA);
if (r<minpr) {minpr=r;}}
string a;
if(bars==1)a="bar: ";
else a= IntegerToString(bars,1) + " bar's: ";
Comment("Last ", a, "max ", DoubleToStr(maxpr, 5), ", min ", DoubleToStr(minpr, 5),".");
}
int BuyLimitCount(){
int count=0;
if(OrderSelect(ticketUP, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUYLIMIT)
count++;}}return(count);}
int BuyCount(){
int count=0;
if(OrderSelect(ticketUP, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicB){
if(OrderType()==OP_BUY)
count++;}}return(count);}
int SellLimitCount(){
int count=0;
if(OrderSelect(ticketD, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicS){
if(OrderType()==OP_SELLLIMIT)
count++;}}return(count);}
int SellCount(){
int count=0;
if(OrderSelect(ticketD, SELECT_BY_TICKET, MODE_TRADES)==true){
if(OrderMagicNumber()==MagicS){
if(OrderType()==OP_SELL)
count++;}}return(count);}
And here there is one moment - after I changed the selection function, the order modify function started to generate an error and only after some time oftesting, at first everything was normal.
Why does this happen and how to deal with it?
You probably get this error because you are trying to modify a pending order that has already been triggered or deleted. You need to reset the variables where the pending ticket is stored, for example, when the pending order has been triggered.
Hi all, help me understand what's wrong.
my Expert Advisor opens ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0, "AV2",1111,0,Green);
for(int prev=0; prev<OrdersTotal();prev++) //Checking of previous EA operation
{
ViborOrdera=OrderSelect(prev,SELECT_BY_POS);
if(OrderSymbol()==Symbol())
//*************************************
//-------Check the Purchasing cycle--------
if(OrderType()==OP_BUY && OrderMagicNumber()==1111)
{
PriceAsk=OrderOpenPrice();//open price, needed for further work of the EA
}
question, where is the error, is there no check? The body of the loop is in the Inite.
No time to sort it out..........
Try to read and place in the right places.
boolRefreshRates();
Hi all, help me understand what's wrong.
my Expert Advisor opens ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0, "AV2",1111,0,Green);
Question, where is the error, there is no check? The body of the loop is in Inite.
No time to sort it out..........
Try to read and place in the right places.
boolRefreshRates();
And prove that it is the cycle that is not going in. Besides, why should we check ALL orders from the very beginning of the account's life if we need the latest ones?
Proof: Print("Previous PriceAsk-",PriceAsk); the log is empty.
Besides, why should we check ALL orders from the very beginning of the account life, if we need the latest ones? - How else to do it, if there are 10 currency pairs open?
Everything was OK until we changed ViborOrdera=OrderSelect(prev,SELECT_BY_POS) in MQL;
It used to beOrderSelect(prev,SELECT_BY_POS);. It was a long time ago), but it worked.