Default stop-loss

To add comments, please log in or register
Forex Trader
114529
Forex Trader  
Hi
I could not find the way to set default Stop-loss and Take profit?
Maybe someone could help me.
For example when I enter a trade the programm should automaticaly
enter pre-set Stop-loss and Take profit.
Lets say 30 pips from filled price.
Thanks
Forex Trader
114529
Forex Trader  
default Stop-loss and Take profit

There is no such a feature in MetaTrader 4 Client Terminal. But you can write your own expert for this.
Forex Trader
114529
Forex Trader  
But you can write your own expert for this. [/quote]

Thank you Tatjana may be one day I will be able to write experts:(
Forex Trader
114529
Forex Trader  
Hi
I could not find the way to set default Stop-loss and Take profit?
Maybe someone could help me.
For example when I enter a trade the programm should automaticaly
enter pre-set Stop-loss and Take profit.
Lets say 30 pips from filled price.
Thanks


This is my code for use as a script file. I assigned ALT +B for buy and ALT +S for sell. The used to work, but haven't since a few releases ago. If any great programmer type would have look to see if they cold be fix, that would be helpful. (UPDATE JUNE 16 2006 The scripts are working again!) Copy the code and make your own script using MT4 MetaEditor..
//+------------------------------------------------------------------+
//| Buy.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#include <stdlib.mqh>
#include <WinUser32.mqh>

double Lots=1.0;
int Slippage=5;
int TakeProfit=99;
int StopLoss=25;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
double MyStopLoss=Ask-StopLoss*Point;
double MyTakeProfit=Ask+TakeProfit*Point;

//----
if(MessageBox("Do you really want to BUY "+DoubleToStr(Lots,2)+" "+Symbol()+" at "+DoubleToStr(Ask,4)+" Price Stoploss at " +DoubleToStr(MyStopLoss,4)+" TakeProfit at "+DoubleToStr(MyTakeProfit,4)+" ? ",
"Buy confirm",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----
int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,MyStopLoss,MyTakeProfit,"Buy",0,0,CLR_NONE);
if(ticket<1)
{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
//----
OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"Buy",0,0,Green);
//----
return(0);
}
//+------------------------------------------------------------------+
======================================================================
//+------------------------------------------------------------------+
//| Sell.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#include <stdlib.mqh>
#include <WinUser32.mqh>

double Lots=1.0;
int Slippage=5;
int TakeProfit=99;
int StopLoss=25;


//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
double MyStopLoss=Bid+StopLoss*Point;
double MyTakeProfit=Bid-TakeProfit*Point;

//----
if(MessageBox("Do you really want to SELL "+DoubleToStr(Lots,2)+" "+Symbol()+" at "+DoubleToStr(Bid,4)+" Price Stoploss at " +DoubleToStr(MyStopLoss,4)+" TakeProfit at "+DoubleToStr(MyTakeProfit,4)+" ? ",
"Sell confirm",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----
int ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,MyStopLoss,MyTakeProfit,"Buy",0,0,CLR_NONE);
if(ticket<1)
{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
}
//+------------------------------------------------------------------+
To add comments, please log in or register