every thing seems to be ok white the code,but unexpected result (its closing the sell order permanently ) i do not understand the logic is :delete the order sell _stop only if ask> pend(H+P+Spread) , i have no idea whats want wrong.
Is this meant as a function:pend(H+P+Spread)? If yes, where is it? If no, what is it? Or have you defined 'pend' as static var somewhere else?
if (Check1 >= Threshold && Check2 >= Threshold && O>L)
{
ticket2=OrderSend(Symbol(),OP_SELLSTOP,Lot,L-P,0,L-P+SL,L-P-TP,NULL,0,iTime( Symbol(), PERIOD_D1, 0 ) + 86400); // <-- place sellstop order and assigne it to ticket2if (ticket2==-1)
{
err=GetLastError();
Print("error(",err,")");
}
}
else
{
Comment("\n","Cannot set OP_SELLSTOP",
"\n","The price is not satisfied to the market entry condition");
}
ClosePendingOrder( symbol,ticket,ticket2); // <-- call ClosePendingOrder and one argument is ticket2//}//+------------------------------------------------------------------+// int total=OrdersTotal();//int TotalOrderCount(string Symbol, int ticket)//{
}<<<<<<<___________end of start
bool ClosePendingOrder(string symbol ,int Ticket,int ticket2)
{
double H,Spread,P,pend; // <-- Unless pend is defined as static var somewhere else, pend is initialised with 0 //int ticket2;if (Ask > pend) // <-- if (Ask>0)if(OrderSelect(ticket2,SELECT_BY_TICKET)==true); // <-- select order with ticket2 if(ticket2==OrderTicket()) // <-- ??? You selecet by ticket, of course this is true! (No need at all to do that).bool orderx= OrderDelete(ticket2,Red); // <-- Delete order with ticket2return(0);
}
No, it isn't. You defined it inside the start function.
ticket2 is overwritten with 0 on the next tick. Either you have to place it in global scope, or you have to select it again in the ClosePendingOrder() function (Select by position and filter for something you identify your order).
And read about timeseries. The second parameter is not intended to be NULL.
No, it isn't. You defined it inside the start function.
ticket2 is overwritten with 0 on the next tick. Either you have to place it in global scope, or you have to select it again in the ClosePendingOrder() function (Select by position and filter for something you identify your order).
And read about timeseries. The second parameter is not intended to be NULL.
the compiler do not let me to put statement on the global scop so..?were do i put the "pend" so the function could read it properly ?
the compiler do not let me to put statement on the global scop so..?were do i put the "pend" so the function could read it properly ?
Declare it globally, assign it anywhere you like, just do it before you call the function . . . and remove the same variable declared as part of the function declaration.
Change this
bool ClosePendingOrder(string symbol ,int Ticket, int ticket2, double pend)
to this
bool ClosePendingOrder(string symbol ,int Ticket, int ticket2)
Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?
Declare it globally, assign it anywhere you like, just do it before you call the function . . . and remove the same variable declared as part of the function declaration.
Change this
to this
Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?
"Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?"
i been checked them bout , it give the seem effect which is do not working properly (it does not close the sell order once the buy order get hit)
*i did modify the function according to your example .
Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?
ticket and ticket2 are globally declared, you don't need to pass then when you call the function . . .
change these
ClosePendingOrder( symbol,ticket,ticket2); <<<<<<<<----linke to the func
bool ClosePendingOrder(string symbol ,int ticket,int ticket2) <<<<<<<<<<<<<<<-----func
to these
ClosePendingOrder( symbol ); // <<<<<<<<----linke to the func
int ClosePendingOrder(string symbol) // <<<<<<<<<<<<<<<-----func
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.
Maybe someone else will look at your code, I'm not in the state it's in.
no problem buddy ,enjoy your weekend , i am not in a rush.
many thanks!!
every thing seems to be ok white the code,but unexpected result (its closing the sell order permanently ) i do not understand the logic is :delete the order sell _stop only if ask> pend(H+P+Spread) , i have no idea whats want wrong.
Is this meant as a function: pend(H+P+Spread)? If yes, where is it? If no, what is it? Or have you defined 'pend' as static var somewhere else?
Is this meant as a function: pend(H+P+Spread)? If yes, where is it? If no, what is it? Or have you defined 'pend' as static var somewhere else?
hi kronin
pend = (H+P+Spread);
it is a global variable .
hi kronin
pend = (H+P+Spread);
it is a global variable .
No, it isn't. You defined it inside the start function.
ticket2 is overwritten with 0 on the next tick. Either you have to place it in global scope, or you have to select it again in the ClosePendingOrder() function (Select by position and filter for something you identify your order).
And read about timeseries. The second parameter is not intended to be NULL.
No, it isn't. You defined it inside the start function.
ticket2 is overwritten with 0 on the next tick. Either you have to place it in global scope, or you have to select it again in the ClosePendingOrder() function (Select by position and filter for something you identify your order).
And read about timeseries. The second parameter is not intended to be NULL.
the compiler do not let me to put statement on the global scop so..?were do i put the "pend" so the function could read it properly ?
the compiler do not let me to put statement on the global scop so..?were do i put the "pend" so the function could read it properly ?
Declare it globally, assign it anywhere you like, just do it before you call the function . . . and remove the same variable declared as part of the function declaration.
Change this
to this
Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?
Declare it globally, assign it anywhere you like, just do it before you call the function . . . and remove the same variable declared as part of the function declaration.
Change this
to this
Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?
"Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?"
i been checked them bout , it give the seem effect which is do not working properly (it does not close the sell order once the buy order get hit)
*i did modify the function according to your example .
any advice?
thanks.
Sort your indenting and braces into some coherent and consistent style and you will probably see where your issue is.
And read about timeseries. The second parameter is not intended to be NULL.
You have been given plenty of advice, you don't seem to want to take it though.
Sort your indenting and { } braces and fix your timeseries calls.
You have been given plenty of advice, you don't seem to want to take it though.
Sort your indenting and { } braces and fix your timeseries calls.
what i am missing here:
*i change the code to be more clear .
it doesnt close the pending sell once the buy order hit!
i am lost!
Which ticket2 do you want to use in your function ? the globally declared one or the locally declared one ? ?
ticket and ticket2 are globally declared, you don't need to pass then when you call the function . . .
change these
to these