wrong code
if(2>1)
because 2 is always greater than 1
if(OrderOpenPrice(ticket_11)==Ask-100*Point)u should use OrderSelect() for this
double OrderPrice = 0; if(2>1) { ticket_11=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"comment",10001,0,Green); if(ticket_11>0) { if(OrderSelect(ticket_11,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY number 11 opened @ ",OrderOpenPrice()); OrderPrice = OrderOpenPrice(); } else Print("Error opening BUY order 11 @ ",GetLastError()); return(0); if (OrderPrice == Ask-100*Point) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"comment",10002,0,Green); } }didn't chack it
didn't chack it
i know the trade logic 2>1 is rubbish, but thats not the important part anyway :)
if (OrderPrice == Ask-100*Point) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"comment",10002,0,Green); }
this isnt working, but thats no surprise, because OrderPrice isnt defined (and has no reference to ticket_11 anyway)
this is what i came up with based on your OrderSelect() recommendation:
if(OrderSelect(ticket_11,SELECT_BY_TICKET,MODE_TRADES)+100*Point==Ask) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit2*Point,"Priceaction - UP",10002,0,Green); }
this shows no errors, but its not opening the new trade...
any more ideas? :S
OrderSelect(ticket_11,SELECT_BY_TICKET,MODE_TRADES); if (OrderClosePrice() == OrderOpenPrice() +100*Point) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit2*Point,"Priceaction - UP",10002,0,Green); }this should be fine
In my opinion should be
>=
& not
==
your code missed a ; sign, but its not working
i came up with this:
OrderSelect(ticket_11,SELECT_BY_TICKET,MODE_TRADES); if(OrderOpenPrice()+100*Point<Ask) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit2*Point,"comment",10002,0,Green); }
basically the same, but i did not use the OrderClosePrice()
after the ticket_12 line i even added a return(0); but that didnt change a thing either
OrderSelect(ticket_11,SELECT_BY_TICKET,MODE_TRADES); if (Ask >= OrderOpenPrice() +100*Point) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit2*Point,"Priceaction - UP",10002,0,Green); }
if ( OrderSelect( ticket_11, SELECT_BY_TICKET ) ) { if ( OrderType() == OP_BUY ) { if ( Bid - OrderOpenPrice() - X_PIP_PROFIT*Point > -Point/2.0 ) { /*OPEN*/ } } if ( OrderType() == OP_SELL ) { if ( OrderOpenPrice() - Ask - X_PIP_PROFIT*Point > -Point/2.0 ) { /*OPEN*/ } } }Give it a try.
thanks for the help guys, the codes work fine. it turned out that i was stupid enough to forget about my own 1 trade limitation, thats why i wasnt getting any new trades.
but one problem comes after another, this is the code im using right now:
if(ticket_11<1) { if(MA_15_high_prev<Bid && High_curr==Ask) { ticket_11=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-SL*Point,Ask+TP1*Point,"Priceaction - UP",10001,0,Green); } } // SECOND BUY if(ticket_12<1) { if(OrderSelect(ticket_11,SELECT_BY_TICKET)) { if(Ask-OrderOpenPrice()>PIPS_TO_NEXT_TRADE*Point) { ticket_12=OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,Bid-SL*Point,Ask+TP1*Point,"Priceaction - UP",10002,0,Green); } } }
no matter if the number of total trades is limited to 2 or 10, the ticket_11 (same for ticket_12) order will be opened several times. so i thought i only need to add a limitation to it, thats why ive added "if(ticket_11<1)" which should be equal to "if there is no ticket_11 opened". ive also tried "if(ticket_11 ==0 )" instead, but multiple trades were opened also. i must have the wrong code for the limitation, so, if someone could tell me the right one, i would appreciate it, thanks!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi
topic title says it all. i want to place a new order once a previous order reaches +10 pips. heres what ive got so far:
the first order gets triggered normally, but im having trouble with the second one. im pretty sure the "if" statement is wrong:
what i wanted to write is: if the open price of order ticket_11 is equal to current ask price minus 100 points (which is 10 pips on 5 digist broker), then open ticket_12
hope someone can help, thanks!