Navigation:Home > Content >

Auto_Currency_Converter_with_Money_Management_DK.mq4

Time: 2016-04-16 | Download file:Auto_Currency_Converter_with_Money_Management_DK.mq4

//+------------------------------------------------------------------+
//|             DK-Auto Currency Converter with Money Management.mq4 |
//|          Darkkiller- Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Darkkiller"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window

extern bool BalanceEquity = true;
extern bool MoneyManagement = true;
extern double Risk = 10;
extern double Rate = 3.5;
extern string Currency= "RM";
extern string Font = "Arial";
extern int Size = 9;
extern int CurrentSize = 15;
extern color Color = DarkGray ;
extern bool SmallComments= false;



int init() {
   
   Comment("");
   return (0);
}

int deinit() {
   ObjectDelete("Converter");
   ObjectDelete("Converter1");
   ObjectDelete("Converter2");
   ObjectDelete("Converter3");
   ObjectDelete("Converter4");
   
   Comment("");
   return (0);
}

double PointCost() {
   double ld_ret_0;
   double ld_8 = MarketInfo(Symbol(), MODE_LOTSIZE) * MarketInfo(Symbol(), MODE_POINT);
   string ls_16 = StringSubstr(Symbol(), 3, 3);
   string l_symbol_24 = "USD" + ls_16;
   string l_symbol_32 = ls_16 + "USD";
   if (ls_16 == "USD") ld_ret_0 = ld_8;
   else {
      if (MarketInfo(l_symbol_24, MODE_BID) != 0.0) ld_ret_0 = ld_8 * (1 / MarketInfo(l_symbol_24, MODE_BID));
      else ld_ret_0 = ld_8 * MarketInfo(l_symbol_32, MODE_ASK);
   }
   return (ld_ret_0);
}

double RiskInPoints() {
   double ld_ret_0 = MathAbs(0.1 - 0) / Point;
   return (ld_ret_0);
}

double PoseSize() {
   double ld_ret_0;
   double ld_8;
   double ld_16 = RiskInPoints();
   if (PointCost() > 0.0 && ld_16 > 0.0) {
      ld_8 = AccountBalance() * Risk / 100.0 / (ld_16 * PointCost());
      ld_ret_0 = MathFloor(10.0 * ld_8) / 10.0;
   } else ld_ret_0 = 0;
   return (ld_ret_0);
}

double AbsoluteRisk() {
   double ld_8 = PoseSize() * RiskInPoints() * PointCost();
   double ld_0 = NormalizeDouble(ld_8, 2);
   return (ld_0);

}

int start() {
   bool li_0;
   if (StringFind(Symbol(), "JPY", 0) != -1) li_0 = FALSE;
   else li_0 = FALSE;
   double ld_4 = NormalizeDouble(MarketInfo(Symbol(), MODE_SPREAD), 0);
   string ls_12 = "\n\n";
   if(SmallComments == true) {
      ls_12 = ls_12 + "Account Balance: " + Currency + DoubleToStr(AccountBalance()*Rate, 2)+ "\n";
        ls_12 = ls_12 + "Account Equity: " + Currency + DoubleToStr(AccountEquity()*Rate, 2)+ "\n\n";
      ls_12 = ls_12 + "Current Profit: " + Currency + DoubleToStr(AccountProfit()*Rate, 2)+"\n\n";
      
       ls_12 = ls_12 + "Recommended Position Size: " + DoubleToStr(PoseSize(), 2) + " lot \n";
      ls_12 = ls_12 + "Risk: " + DoubleToStr(Risk, 2) + " % ";
      ls_12 = ls_12 + "Absolute Risk: "+ "USD " + DoubleToStr(AbsoluteRisk(), 2) + " "; ls_12 = ls_12 + "("+ Currency + DoubleToStr(AbsoluteRisk()*Rate, 2) +") \n";
      
      
      Comment(ls_12);
   }
   if (BalanceEquity) 
   ObjectCreate("Converter", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Converter", "Account Balance: " + Currency + DoubleToStr(AccountBalance()*Rate, 2)+ "", Size, Font, Color);
   ObjectSet("Converter", OBJPROP_CORNER, 3);
   ObjectSet("Converter", OBJPROP_XDISTANCE, 3);
   ObjectSet("Converter", OBJPROP_YDISTANCE, 85);
   
   if (BalanceEquity) 
   ObjectCreate("Converter1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Converter1", "Account Equity: " + Currency + DoubleToStr(AccountEquity()*Rate, 2)+ "", Size, Font, Color);
   ObjectSet("Converter1", OBJPROP_CORNER, 3);
   ObjectSet("Converter1", OBJPROP_XDISTANCE, 3);
   ObjectSet("Converter1", OBJPROP_YDISTANCE, 70);
   
   ObjectCreate("Converter2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Converter2", "Current Profit: " + Currency + DoubleToStr(AccountProfit()*Rate, 2)+ "", CurrentSize, Font, Color);
   ObjectSet("Converter2", OBJPROP_CORNER, 3);
   ObjectSet("Converter2", OBJPROP_XDISTANCE, 3);
   ObjectSet("Converter2", OBJPROP_YDISTANCE, 45);
   
   if (MoneyManagement) 
   ObjectCreate("Converter3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Converter3", "Recommended Position Size: " + DoubleToStr(PoseSize(), 2) + " lot", Size, Font, Color);
   ObjectSet("Converter3", OBJPROP_CORNER, 3);
   ObjectSet("Converter3", OBJPROP_XDISTANCE, 3);
   ObjectSet("Converter3", OBJPROP_YDISTANCE, 30);
    
   if (MoneyManagement) 
   ObjectCreate("Converter4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Converter4", "Risk: " + DoubleToStr(Risk, 2) + " % "+"["+ Currency +DoubleToStr(AbsoluteRisk()*Rate, 2)+ "="+"USD" +DoubleToStr(AbsoluteRisk(), 2)+"]", Size, Font, Color);
   ObjectSet("Converter4", OBJPROP_CORNER, 3);
   ObjectSet("Converter4", OBJPROP_XDISTANCE, 3);
   ObjectSet("Converter4", OBJPROP_YDISTANCE, 15);
   }
    return (0);

Recommend