Mohammad Rizal Bin Rahmat:
Check you if statements, it should be "==" not "=". Declare vask and vbid within start statement and remove ().
Hi, i'm trying to recreate a EA to delete pending order when it hit the price i input. But kept having error. tried to google up, but not able to. Or maybe the code i do is wrong? anyone could help please? thanks
Your error was '{' - unbalanced parentheses.
That mean if you have opened parentheses '{', then it must be always closed '}'
And maybe some other little mistakes.
Try this:
That mean if you have opened parentheses '{', then it must be always closed '}'
And maybe some other little mistakes.
Try this:
int start() { if(Ask==Price_Target || Bid==Price_Target) { for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i, SELECT_BY_POS)) continue; //--- bool result = false; if(OrderType()>1 && OrderSymbol()==Symbol()) result = OrderDelete( OrderTicket() ); //--- if(!result) Sleep(0); } Print ("Account Price Reached. All Pending Order Have Been Deleted"); } Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(), "\nMy Account Profit Target: ",Price_Target); return(0); }
But in this case it also probably will not ever trigger. Because Ask can jump over Price_Target and never will equal to it.
So you must to check in such way:
So you must to check in such way:
if((iOpen(NULL,PERIOD_M1,0)<=Price_Target && Ask >= Price_Target) || (iOpen(NULL,PERIOD_M1,0)>=Price_Target && Bid <= Price_Target)) { .... delete pending }
Lazar Buga:
But in this case it also probably will not ever trigger. Because Ask can jump over Price_Target and never will equal to it.
So you must to check in such way:
Hi Lazar,But in this case it also probably will not ever trigger. Because Ask can jump over Price_Target and never will equal to it.
So you must to check in such way:
Thank you for guiding. Ok i understand about the need to have "<" or ">". Will try it out...
Is this part still ok or it is wrong too?
double vbid= MarketInfo("Symbol",MODE_BID); double vask= MarketInfo("Symbol",MODE_ASK);
Mohammad Rizal Bin Rahmat:
You can always check anything you need.Is this part still ok or it is wrong too?
Just make data visible for you.
For example you can use Print();
int OnInit() { //--- Print("Correct = "+ MarketInfo(Symbol(),MODE_BID)); Print("Wrong = " + MarketInfo("Symbol",MODE_BID)); //--- return(INIT_SUCCEEDED); }Then go to the 'Experts' and check it.
You will see:
http://prntscr.com/bg9qtl
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
Hi, i'm trying to recreate a EA to delete pending order when it hit the price i input. But kept having error. tried to google up, but not able to. Or maybe the code i do is wrong? anyone could help please? thanks