Can anyone help to make minor changes to this code please?
I would like the SL range from 5 pips to 20 pips.
If anyone can help I'll need new code as a .mq4 file
Regards
Rob
#property copyright ""
#property link ""
#property strict
#property indicator_separate_window
extern int FontSize=8;
extern color FontColor=DeepSkyBlue;
extern int XDistance=10;// X location
extern int YDistance=10;// Y location
extern double Risk=2;// Risk (%)
//--------------------------------------------------------------------
int init()
{
IndicatorShortName("");
return(0);
}
int deinit()
{
Comment("");
ObjectsDeleteAll();
return(0);
}
//--------------------------------------------------------------------
int BarsCount = 0;
int totalprofit = 0;
int totalloss = 0;
int countbuy = 0;
int countsell = 0;
int start()
{
double bal = AccountEquity();
string s = "SL (pips)|";
string s2 = "Lot Size |";
make_label("sl",s,XDistance,YDistance);
make_label("lots",s2,XDistance,YDistance+(FontSize*2));
for(int i = 0; i <= 20; i++)
{
double lot = (bal*(Risk/100.0)) / ((10+i)*10* MarketInfo(Symbol(), MODE_TICKVALUE));
if(0.01 == MarketInfo(0,MODE_MINLOT))
{
lot = NormalizeDouble(lot,2);
if(lot < 0.01){lot = 0.01;}
else{}
}
else if(0.1 == MarketInfo(0,MODE_MINLOT))
{
lot = NormalizeDouble(lot,1);
if(lot < 0.1){lot = 0.1;}
else{}
}
else if(1.0 == MarketInfo(0,MODE_MINLOT))
{
lot = NormalizeDouble(lot,0);
if(lot < 1.0){lot = 1.0;}
else{}
}
else{}
s = (10+i)+" |";
s2 = DoubleToStr(lot,2)+" |";
make_label("sl"+i,s,XDistance+(0+(FontSize*8))+((10+(FontSize*4))*i),YDistance);
make_label("lots"+i,s2,XDistance+(0+(FontSize*8))+((10+(FontSize*4))*i),YDistance+(FontSize*2));
}
return(0);
}
void DrawPriceHHLine(datetime x1, datetime x2, double y1,
double y2, color lineColor, double style)
{
string label = "HHLine.0# " + DoubleToStr(x2, 0) + lineColor;
ObjectDelete(label);
ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);
ObjectSet(label, OBJPROP_RAY, 0);
ObjectSet(label, OBJPROP_COLOR, lineColor);
ObjectSet(label, OBJPROP_STYLE, style);
ObjectSet(label, OBJPROP_WIDTH, 1);
}
void make_label(string sl,string l,int x,int y)
{
ObjectCreate("l"+sl, OBJ_LABEL, WindowsTotal()-1, 0, 0);
ObjectSetText("l"+sl, l , FontSize, "Verdana", FontColor);
ObjectSet("l"+sl, OBJPROP_CORNER, 0);
ObjectSet("l"+sl, OBJPROP_XDISTANCE, x);
ObjectSet("l"+sl, OBJPROP_YDISTANCE, y);
}
I would like the SL range from 5 pips to 20 pips.
If anyone can help I'll need new code as a .mq4 file
Regards
Rob
#property copyright ""
#property link ""
#property strict
#property indicator_separate_window
extern int FontSize=8;
extern color FontColor=DeepSkyBlue;
extern int XDistance=10;// X location
extern int YDistance=10;// Y location
extern double Risk=2;// Risk (%)
//--------------------------------------------------------------------
int init()
{
IndicatorShortName("");
return(0);
}
int deinit()
{
Comment("");
ObjectsDeleteAll();
return(0);
}
//--------------------------------------------------------------------
int BarsCount = 0;
int totalprofit = 0;
int totalloss = 0;
int countbuy = 0;
int countsell = 0;
int start()
{
double bal = AccountEquity();
string s = "SL (pips)|";
string s2 = "Lot Size |";
make_label("sl",s,XDistance,YDistance);
make_label("lots",s2,XDistance,YDistance+(FontSize*2));
for(int i = 0; i <= 20; i++)
{
double lot = (bal*(Risk/100.0)) / ((10+i)*10* MarketInfo(Symbol(), MODE_TICKVALUE));
if(0.01 == MarketInfo(0,MODE_MINLOT))
{
lot = NormalizeDouble(lot,2);
if(lot < 0.01){lot = 0.01;}
else{}
}
else if(0.1 == MarketInfo(0,MODE_MINLOT))
{
lot = NormalizeDouble(lot,1);
if(lot < 0.1){lot = 0.1;}
else{}
}
else if(1.0 == MarketInfo(0,MODE_MINLOT))
{
lot = NormalizeDouble(lot,0);
if(lot < 1.0){lot = 1.0;}
else{}
}
else{}
s = (10+i)+" |";
s2 = DoubleToStr(lot,2)+" |";
make_label("sl"+i,s,XDistance+(0+(FontSize*8))+((10+(FontSize*4))*i),YDistance);
make_label("lots"+i,s2,XDistance+(0+(FontSize*8))+((10+(FontSize*4))*i),YDistance+(FontSize*2));
}
return(0);
}
void DrawPriceHHLine(datetime x1, datetime x2, double y1,
double y2, color lineColor, double style)
{
string label = "HHLine.0# " + DoubleToStr(x2, 0) + lineColor;
ObjectDelete(label);
ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);
ObjectSet(label, OBJPROP_RAY, 0);
ObjectSet(label, OBJPROP_COLOR, lineColor);
ObjectSet(label, OBJPROP_STYLE, style);
ObjectSet(label, OBJPROP_WIDTH, 1);
}
void make_label(string sl,string l,int x,int y)
{
ObjectCreate("l"+sl, OBJ_LABEL, WindowsTotal()-1, 0, 0);
ObjectSetText("l"+sl, l , FontSize, "Verdana", FontColor);
ObjectSet("l"+sl, OBJPROP_CORNER, 0);
ObjectSet("l"+sl, OBJPROP_XDISTANCE, x);
ObjectSet("l"+sl, OBJPROP_YDISTANCE, y);
}
Your trade order needs to be in the right place at the right time.