double point = MarketInfo(Symbol(),MODE_POINT);
point is always equal to Point, so what's the point.- Always count down when modifying/closing/deleting in the presense of multiple order (multiple charts)
- If there are NO open order, the for loop won't execute, so no orderSend. If there were multiple open orders (non buyStops) then the loop would create multiple buyStops.
- Your loop is counting n, but the order select is use pos.
int count=0; for(pos=OrdersTotal()-1; pos >= 0; pos--) if ( OrderSelect(pos, SELECT_BY_POS) && OrderMagicNumber() == 1 && OrderSymbol() == Symbol() ) count++; if (!count) { if (!OrderSend( Symbol(), OP_BUYSTOP, 0.1, Ask+6*point, 4, Bid-52*point, Bid+20*point, "A BUY", 1, expiration, Blue)){ Alert("Unable to send A BUY", GetLastError()); } }
- For 5 digit brokers, you must adjust pips (OP/SL/TP) and points (slippage). For ECN brokers you must wait for the order to open, then set TP/SL
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
Some comments to help you understand code
int start() { //---- double ABUY=0; double point = MarketInfo(Symbol(),MODE_POINT); double expiration=CurTime()+PERIOD_D1*60; int pos; int n; int total= OrdersTotal(); for( n=0; n<total; n++ )//start n at zero, while n is strictly less than total repeat the code block increasing n by 1 when code block ends { // count orders OrderSelect(pos, SELECT_BY_POS) ; //select from a table/array of open orders the one in the row specified by pos (note pos does not change in this code) //this is a command to the brokers server as orders are not held by the client OrderTicket=0 means no order selected if ( (OrderMagicNumber()==1) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUYSTOP) ) //does the order selected have these properties { // Order type ABUY= 2; } else // if the orderselected does not have the above properties then { //start of else code block, without curly bracket next line ONLY is the code block if (!OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+6*point,4,Bid-52*point,Bid+20*point,"A BUY",1,expiration,Blue)) { Alert("Unable to send A BUY", GetLastError()); } // end of if not OrderSend code block } }//end of for loop code block //---- return(0); }

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
The problem is that I can't start my first strategy. I can't send the orders.
This is the code i use to check if order with MagicNumber exists and if not than strategy should send the order.
Anybody knows what is wrong and why this isn't sending orders?