Hello guys, I need help with SL and TP I need the code to take profit at the next cross over not like points or pips if you need more explaining tell me .
THANK YOU.
Hello,
Just a question : why do you do ordersend then ordermodify ?
int OrderSend( string symbol, // symbol int cmd, // operation double volume, // volume double price, // price int slippage, // slippage double stoploss, // stop loss double takeprofit, // take profit string comment=NULL, // comment int magic=0, // magic number datetime expiration=0, // pending order expiration color arrow_color=clrNONE // color );
There is a particular reason ?
You have an example on MQL4 help :
//--- get minimum stop level double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL); Print("Minimum Stop Level=",minstoplevel," points"); double price=Ask; //--- calculated SL and TP prices must be normalized double stoploss=NormalizeDouble(Bid-minstoplevel*Point,Digits); double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits); //--- place market order to buy 1 lot int ticket=OrderSend(Symbol(),OP_BUY,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); //---
hi I'm not sure I get you sir all I need to modify my code instead of take profit of 100 pips I need it to take profit when an indicator do some kind of condition lets say when the 2 ma above cross over.
I know I cant explain it well its not my first language :) so if you need me to clarify any information send me back.
hi I'm not sure I get you sir all I need to modify my code instead of take profit of 100 pips I need it to take profit when an indicator do some kind of condition lets say when the 2 ma above cross over.
I know I cant explain it well its not my first language :) so if you need me to clarify any information send me back.
I think (if i've not mistaken you) you have to add OrderClose function when the condition met.
I think (if i've not mistaken you) you have to add OrderClose function when the condition met.
Hi, I think you answered my question :)
so I replace this code (code below) with OrderClose ? can you give me an example just to fully get it
ticket= OrderSend(Symbol(),OP_BUY,lotSize,Ask,3,0,0,NULL,0,0,Green); if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) rst=OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()-(stopLose*Point),OrderOpenPrice()+(takeProfit*Point),0,CLR_NONE);
Hi, I think you answered my question :)
so I replace this code (code below) with OrderClose ? can you give me an example just to fully get it
if(fastMaV2<slowMaV2&& fastMaV1>slowMaV1&& OrdersTotal()==0 ) { if(!OrderClose(ticket,lots,Ask/Bid,slippage,color)return;}
I think its tricky, I think I need OrderOpen also to enter the trade then I use OrderClose is there any article I can study this part .
And Thank You Very Much Sir.
I think its tricky, I think I need OrderOpen also to enter the trade then I use OrderClose is there any article I can study this part .
And Thank You Very Much Sir.
This book might be useful to understand mql4. There have many samples of programs.
book.mql4.com

- book.mql4.com
Hello,
This code can't work, because you check OrdersTotal == 0 then you can't close an order if they are not open...
maybe like this :
if(fastMaV2<slowMaV2&& fastMaV1>slowMaV1&& OrdersTotal()==0 ) { //openorder } if(fastMaV2<slowMaV2&& fastMaV1>slowMaV1&& OrdersTotal()>0 ) //replace fastMaV2<slowMaV2&& fastMaV1>slowMaV1 by your conditions to close order { //closeorder }
Hello,
This code can't work, because you check OrdersTotal == 0 then you can't close an order if they are not open...
maybe like this :
Thank You Sir really helped me now all I need to do is how to openorder and closeorder you saved me a lot of time thank you again :)
Thank You Sir really helped me now all I need to do is how to openorder and closeorder you saved me a lot of time thank you again :)
Hi again why it open the trade but never close it ?
if(fastMaV2<slowMaV2&& fastMaV1>slowMaV1&& OrdersTotal()==0 ) { buyticket= OrderSend(Symbol(),OP_BUY,lotSize,Ask,3,0,0,NULL,0,0,Green); // assuming I identify the variable buyticket and closeticket } if(fastMaV2<slowMaV2&& fastMaV1>slowMaV1&& OrdersTotal()>0 ) { closeticket=OrderClose(OrderTicket(),OrderLots(),Ask,3,Red); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello guys, I need help with SL and TP I need the code to take profit at the next cross over not like points or pips if you need more explaining tell me .
THANK YOU.