Publicado: 26 Oct 2009 00:18
He hecho unos retoques por que no me iba muy bien. Creo que ahora va bien, si no, pues se vuelve a corregir.
Saludos
/+------------------------------------------------------------------+
//| PotitionSizeCalc.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. Ciclo y NsTrader |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp. Ciclo y nsTrader"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//---- input parameters
extern double risk=3;
extern int TFrameATR=0;
extern int periodATR=7;
extern string nota_dist_SL="Si dist_SL= 0 then dist_SL= automatico";
extern int dist_SL=0;
extern string nota_k="Si dist_SL= 0 then dist_SL=k*ATR(n)";
extern double k=2.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double riesgo=risk/100;
int dist=dist_SL;
if (dist_SL==0)dist=k*iATR(NULL,TFrameATR,periodATR,0)/Point;
Comment("");
double tickValue=MarketInfo (Symbol(), MODE_TICKVALUE);
double equity = AccountEquity();
double size= equity*riesgo/dist/tickValue;
string Com = StringConcatenate("con riesgo= ",riesgo*100,"% y distancia SL=",dist,", potition size= ",DoubleToStr(size,2));
Comment(Com);
//----
return(0);
}
//+------------------------------------------------------------------+
Saludos
/+------------------------------------------------------------------+
//| PotitionSizeCalc.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. Ciclo y NsTrader |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp. Ciclo y nsTrader"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//---- input parameters
extern double risk=3;
extern int TFrameATR=0;
extern int periodATR=7;
extern string nota_dist_SL="Si dist_SL= 0 then dist_SL= automatico";
extern int dist_SL=0;
extern string nota_k="Si dist_SL= 0 then dist_SL=k*ATR(n)";
extern double k=2.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double riesgo=risk/100;
int dist=dist_SL;
if (dist_SL==0)dist=k*iATR(NULL,TFrameATR,periodATR,0)/Point;
Comment("");
double tickValue=MarketInfo (Symbol(), MODE_TICKVALUE);
double equity = AccountEquity();
double size= equity*riesgo/dist/tickValue;
string Com = StringConcatenate("con riesgo= ",riesgo*100,"% y distancia SL=",dist,", potition size= ",DoubleToStr(size,2));
Comment(Com);
//----
return(0);
}
//+------------------------------------------------------------------+