Colocacion de stop loss automaticamente al lanzar una orden
Colocacion de stop loss automaticamente al lanzar una orden
Hola, alguien sabe decirme como debo hacer para que al lanzar una orden se me coloque el stop loss automaticamente?
-------------------------------------
Cuando el barco comienza a hundirse, no reces, salta !
Cuando el barco comienza a hundirse, no reces, salta !
Lo que pasa es que solo he trabajado con metatrader , entonces toy con XTB que me parece que con los spread que tiene en forex vale la pena.
Siempre he utilizado el stop mental, ahora tambien haré lo mismo pero antes tenia conexion en casa pero por trabajo me he tenido que desplazar, me pillé internet movil y lo que me da miedo es perder la conexion en medio de una operacion y se me lie la gorda. Manualmente podria hacerlo pero perderia un tiempo precioso porque me gustan los time frame pequeños.
Gracias por la informacion rufus !
Siempre he utilizado el stop mental, ahora tambien haré lo mismo pero antes tenia conexion en casa pero por trabajo me he tenido que desplazar, me pillé internet movil y lo que me da miedo es perder la conexion en medio de una operacion y se me lie la gorda. Manualmente podria hacerlo pero perderia un tiempo precioso porque me gustan los time frame pequeños.
Gracias por la informacion rufus !
-------------------------------------
Cuando el barco comienza a hundirse, no reces, salta !
Cuando el barco comienza a hundirse, no reces, salta !
Muchas gracias eurer, voy a empezar a estudiar un poco de programacion xq me vendrá muy bien, tengo tanto que aprender y no se puede tanto tan rapido.
//+------------------------------------------------------------------+
//| close.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property show_confirm
//+------------------------------------------------------------------+
//| script "close first market order if it is first in the list" |
//+------------------------------------------------------------------+
int start()
{
bool result;
double price;
int cmd,error;
//----
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
cmd=OrderType();
//---- first order is buy or sell
if(cmd==OP_BUY || cmd==OP_SELL)
{
while(true)
{
if(cmd==OP_BUY) price=Bid;
else price=Ask;
result=OrderClose(OrderTicket(),OrderLots(),price,3,CLR_NONE);
if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
else error=0;
if(error==135) RefreshRates();
else break;
}
}
}
else Print( "Error when order select ", GetLastError());
//----
return(0);
}
//+------------------------------------------------------------------+
A ver si me vale xq no entiendo nada, lo voy a probar a ver que me sale.
Saludos !!
//+------------------------------------------------------------------+
//| close.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property show_confirm
//+------------------------------------------------------------------+
//| script "close first market order if it is first in the list" |
//+------------------------------------------------------------------+
int start()
{
bool result;
double price;
int cmd,error;
//----
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
cmd=OrderType();
//---- first order is buy or sell
if(cmd==OP_BUY || cmd==OP_SELL)
{
while(true)
{
if(cmd==OP_BUY) price=Bid;
else price=Ask;
result=OrderClose(OrderTicket(),OrderLots(),price,3,CLR_NONE);
if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
else error=0;
if(error==135) RefreshRates();
else break;
}
}
}
else Print( "Error when order select ", GetLastError());
//----
return(0);
}
//+------------------------------------------------------------------+
A ver si me vale xq no entiendo nada, lo voy a probar a ver que me sale.
Saludos !!
-------------------------------------
Cuando el barco comienza a hundirse, no reces, salta !
Cuando el barco comienza a hundirse, no reces, salta !
Aplicate esta script cuando tengas ya abiertas las ordenes ...
//+------------------------------------------------------------------+
//| StopLossMove.mq4 |
//| |
//| |
//| Bookkeeper, 2006, [email protected] |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//+------------------------------------------------------------------+
extern int Distance=5; // Distancia del Stop Loss |
extern bool UpDoun=true; // =false |
// =true |
//+------------------------------------------------------------------+
void start()
{
double NewPrice;
int i,Total,Dist;
int Dgts=MarketInfo(Symbol(),MODE_DIGITS);
bool GoGo;
//+------------------------------------------------------------------+
// if(Distance<10>0)
{
for(i=Total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{
NewPrice=Ask+Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()>NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
{
NewPrice=Bid-Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()<NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
}
}
}
}
//+------------------------------------------------------------------+
Un saludo
//+------------------------------------------------------------------+
//| StopLossMove.mq4 |
//| |
//| |
//| Bookkeeper, 2006, [email protected] |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//+------------------------------------------------------------------+
extern int Distance=5; // Distancia del Stop Loss |
extern bool UpDoun=true; // =false |
// =true |
//+------------------------------------------------------------------+
void start()
{
double NewPrice;
int i,Total,Dist;
int Dgts=MarketInfo(Symbol(),MODE_DIGITS);
bool GoGo;
//+------------------------------------------------------------------+
// if(Distance<10>0)
{
for(i=Total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{
NewPrice=Ask+Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()>NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
{
NewPrice=Bid-Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()<NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
}
}
}
}
//+------------------------------------------------------------------+
Un saludo
Aplicate esta script cuando tengas ya abiertas las ordenes ...
//+------------------------------------------------------------------+
//| StopLossMove.mq4 |
//| |
//| |
//| Bookkeeper, 2006, [email protected] |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//+------------------------------------------------------------------+
extern int Distance=5; // Distancia del Stop Loss |
extern bool UpDoun=true; // =false |
// =true |
//+------------------------------------------------------------------+
void start()
{
double NewPrice;
int i,Total,Dist;
int Dgts=MarketInfo(Symbol(),MODE_DIGITS);
bool GoGo;
//+------------------------------------------------------------------+
// if(Distance<10>0)
{
for(i=Total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{
NewPrice=Ask+Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()>NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
{
NewPrice=Bid-Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()<NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
}
}
}
}
//+------------------------------------------------------------------+
Un saludo
//+------------------------------------------------------------------+
//| StopLossMove.mq4 |
//| |
//| |
//| Bookkeeper, 2006, [email protected] |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//+------------------------------------------------------------------+
extern int Distance=5; // Distancia del Stop Loss |
extern bool UpDoun=true; // =false |
// =true |
//+------------------------------------------------------------------+
void start()
{
double NewPrice;
int i,Total,Dist;
int Dgts=MarketInfo(Symbol(),MODE_DIGITS);
bool GoGo;
//+------------------------------------------------------------------+
// if(Distance<10>0)
{
for(i=Total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{
NewPrice=Ask+Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()>NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
{
NewPrice=Bid-Dist*Point;
if(UpDoun==true) GoGo=true;
else
{
if(OrderStopLoss()<NewPrice) GoGo=true;
else GoGo=false;
}
if(GoGo==true) if(OrderModify(OrderTicket(),
OrderOpenPrice(),
NormalizeDouble(NewPrice,Dgts),
OrderTakeProfit(),
OrderExpiration(),
CLR_NONE)!=TRUE)
Print("LastError = ", GetLastError());
}
}
}
}
}
//+------------------------------------------------------------------+
Un saludo
En muchos brokers de metatrader si que puedes poner el stop y/o el takeprofit al mismo tiempo que pones la orden.
Lo acabo de probar en activtrades, sin problemas.
Y en los brokers que no dejen lo mas sencillo es clikear por ejemplo en la columna 'S/L' y sale una ventanita para modificaciones donde puedes poner el stop o el tp en un momento, tanto o mas rapido que cualquier script o EA que fueses a utilizar.
Lo acabo de probar en activtrades, sin problemas.
Y en los brokers que no dejen lo mas sencillo es clikear por ejemplo en la columna 'S/L' y sale una ventanita para modificaciones donde puedes poner el stop o el tp en un momento, tanto o mas rapido que cualquier script o EA que fueses a utilizar.
Si te ha gustado este hilo del Foro, ¡compártelo en redes!