Another good way would be to have the ability to set default values for SL and TP. Ideally for each pair or for all at once.
By opening a order, these values should be taken to preset SL and TP.
cori.
By opening a order, these values should be taken to preset SL and TP.
cori.
an alternative is to create a buy and sell script and copy the attached code into them. so you can set standard lots, tp, sl and trailing stop values. whenever you want to buy or sell you select the appropriate script.
buy script
buy script
//+------------------------------------------------------------------+ //| trade"buy".mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #include <stdlib.mqh> #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //+------------------------------------------------------------------+ //| script "buy" | //+------------------------------------------------------------------+ extern double TakeProfit = 30; extern double StopLoss = 15; extern double Lots = 1.0; extern double TrailingStop = 15; int start() { int ticket; //---- while(true) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"buy opened",255,0,Lime); if(ticket<=0) { int error=GetLastError(); Print("Error = ",ErrorDescription(error)); if(error==134) break; // not enough money if(error==135) RefreshRates(); // prices changed break; } //---- remove break statement below and take trading for all money else { OrderPrint(); break; } //---- 10 seconds wait Sleep(10000); } return(0); // exit } if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0); } } //---- return(0); } //+------------------------------------------------------------------+
sell script
//+------------------------------------------------------------------+ //| trade"sell".mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #include <stdlib.mqh> #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //+------------------------------------------------------------------+ //| script "buy" | //+------------------------------------------------------------------+ extern double TakeProfit = 30; extern double StopLoss = 15; extern double Lots = 1.0; extern double TrailingStop = 0; int start() { int ticket; //---- while(true) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"sell opened",255,0,Red); if(ticket<=0) { int error=GetLastError(); Print("Error = ",ErrorDescription(error)); if(error==134) break; // not enough money if(error==135) RefreshRates(); // prices changed break; } //---- remove break statement below and take trading for all money else { OrderPrint(); break; } //---- 10 seconds wait Sleep(10000); } return(0); // exit } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } //---- return(0); } //+------------------------------------------------------------------+
This is also a good idea, since it is not necessary to go through the Order dialog. Simply start the script when you want to buy. Thank you for this
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
Suggestion to Metaquotes: Will it be possible for you to insert the buttons in the "new order" window that exits in the "modify order" window? I mean those where you select SL and TP, press the burrons, press 'modify' and SL and TP is added/changed in the original order.
It would simplify order entry quite dramatically as there would be no need to type it in (mistakes do happen that way).
Regards
JF