the target is to delete one pending order once the other hit.(in thise case only the sell buy need to delete)
thanks.
Sort your indenting and braces into some coherent and consistent style and you will probably see where your issue is.
User defined functions do not belong within other functions, they are defined outside of all other functions, they are called from inside functions.
Sort your indenting and braces into some coherent and consistent style and you will probably see where your issue is.
User defined functions do not belong within other functions, they are defined outside of all other functions, they are called from inside functions.
thanks .
now i have problem white the "scop"
// int total=OrdersTotal(); //int TotalOrderCount(string Symbol, int ticket) //{ }<<<<<<<<-----start end bool ClosePendingOrder(string Symbol, int Ticket) { if (Ask > (H+P+Spread)) if ( OrderSelect(ticket2,SELECT_BY_TICKET)== true) if(ticket2==OrderTicket()) bool orderx= OrderDelete(ticket2,Red); return(0); }
do i need variables declare in the function?
ok its fix!!
but i get an error when i try to connect the function. can you take a look?
//======================= condition for ORDER BUY =============================== if (Check1 >= Threshold && Check2 >= Threshold && O<H) { ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,H+P+Spread,0,H+P-SL+Spread,H+P+TP+Spread,NULL,0,iTime( Symbol(), PERIOD_D1, 0 ) + 86400); ClosePendingOrder( symbol , int Ticket);<<<<<<<<<----')' - comma or semicolon expected ????? if (ticket==-1) { err=GetLastError(); Print("error(",err,")"); } } else { Comment("\n","Cannot set OP_BUYSTOP", "\n","The price is not satisfied to the market entry condition"); }
many thanks :-)
ok its fix!!
but i get an error when i try to connect the function. can you take a look?
many thanks :-)
When you call a function you pass it the variables it requires to be able to do what you need it to do . . .
ticket = OrderSend(Symbol(), OP_BUYSTOP, Lot, H+P+Spread, 0, H+P-SL+Spread, H+P+TP+Spread, NULL, 0, iTime( Symbol(), PERIOD_D1, 0 ) + 86400); ClosePendingOrder( symbol , ticket); // ticket variable from the OrderSend above ?
Although I don't understand why you would open a pending order and then immediately try to close it ? ?
When you call a function you pass it the variables it requires to be able to do what you need it to do . . .
Although I don't understand why you would open a pending order and then immediately try to close it ? ?
yes , do i need to include just the "H+P+Spread" ?(or all the variables )
i am closing if the "ask> H+P+Spread".
thanks
Are the variables concerned local or globally defined ? if local you will need to pass them to the function or make them globals.
globals,
* now its "pend=H+P+Spread"
bu still, its give me "comma or semicolon expected"
//======================= condition for ORDER BUY =============================== if (Check1 >= Threshold && Check2 >= Threshold && O<H) { ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,H+P+Spread,0,H+P-SL+Spread,H+P+TP+Spread,NULL,0,iTime( Symbol(), PERIOD_D1, 0 ) + 86400); if (ticket==-1) { err=GetLastError(); Print("error(",err,")"); } } else { Comment("\n","Cannot set OP_BUYSTOP", "\n","The price is not satisfied to the market entry condition"); } ClosePendingOrder( symbol , int Ticket)<<<<<<<<<------------here--- "semicolon or comma expected " //================================ condition for ORDER SELL ==================== 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); if (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"); } //} //+------------------------------------------------------------------+ // int total=OrdersTotal(); //int TotalOrderCount(string Symbol, int ticket) //{ } bool ClosePendingOrder(string symbol , int Ticket,double pend) { double H,Spread,P; int ticket2; if (Ask > pend) if ( OrderSelect(ticket2,SELECT_BY_TICKET)== true) if(ticket2==OrderTicket()) bool orderx= OrderDelete(ticket2,Red); return(0); } i been trying the semicolon so i gess its the comma issue now.
any advice?
thanks.
globals,
* now its "pend=H+P+Spread"
bu still, its give me "comma or semicolon expected"
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.
any advice?
many thanks.
the code:
//======================= condition for ORDER BUY =============================== if (Check1 >= Threshold && Check2 >= Threshold && O<H) { ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,H+P+Spread,0,H+P-SL+Spread,H+P+TP+Spread,NULL,0,iTime( Symbol(), PERIOD_D1, 0 ) + 86400); if (ticket==-1) { err=GetLastError(); Print("error(",err,")"); } } else { Comment("\n","Cannot set OP_BUYSTOP", "\n","The price is not satisfied to the market entry condition"); } //================================ condition for ORDER SELL ==================== 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); if (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);<<<<<<<<<<<<<<<<---------------- //} //+------------------------------------------------------------------+ // 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; //int ticket2; if (Ask > pend)<<<<<<<<<<<<<<<<<<<<<<<<-----------the calcultion if(OrderSelect(ticket2,SELECT_BY_TICKET)==true); if(ticket2==OrderTicket()) bool orderx= OrderDelete(ticket2,Red); return(0); }
Sort your indenting and braces into some coherent and consistent style . . .
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
the target is to delete one pending order once the other hit.(in thise case only the stop_sell need to delete)
thanks.