4 Digits & 2 Digits

To add comments, please log in or register
Sameer
779
Sameer  

Could someone assist in modifying this code, so that, current market price is display properly for both pairs type:  1.0000 and 10.00

I have managed to clear up all the errors :)


//+------------------------------------------------------------------+
//| Magnified Market Price            ver1.0                         |
//+------------------------------------------------------------------+

#property indicator_chart_window


//:::::::::::::::::::::::::::::::::::::::::::::
#include <mt4accountinfo.mqh>
#include <mt4string.mqh>
#include <mt4datetime.mqh>
#include <mt4objects_1.mqh>
#include <mt4timeseries_2.mqh>
//Etc.
//:::::::::::::::::::::::::::::::::::::::::::::::

  input string note1 = "Change font colors automatically? True = Yes";
  input string note2 = "Default Font Color";
  input color FontColor = Black;
  input color FontColor2 = Black;
  input string note3 = "Font Size";
  input int    FontSize=12;
  input string note4 = "Font Type";
  input string FontType="Comic Sans MS";
  input string note5 = "Display the price in what corner?";
  input string note6 = "Upper left=0; Upper right=1";
  input string note7 = "Lower left=2; Lower right=3";
  input int    WhatCorner=1;

  double        Old_Price;
  double        Old_Price2;

int OnInit()
  {
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

   return(0);
  }

int OnDeinit()
  {
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

  ObjectDelete("Market_Price_Label"); 
  
  return(0);
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

  

   string Market_Price2 = DoubleToString(Ask,4);
   string Market_Price = DoubleToString(Bid,4);
  

   ObjectCreate("Market_Price_Label2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Market_Price_Label2", Market_Price2, FontSize, FontType, FontColor2);
   ObjectSet("Market_Price_Label2", OBJPROP_CORNER, WhatCorner);
   ObjectSet("Market_Price_Label2", OBJPROP_XDISTANCE, 1);
   ObjectSet("Market_Price_Label2", OBJPROP_YDISTANCE, 1);
   ObjectCreate("Market_Price_Label", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Market_Price_Label", Market_Price, FontSize, FontType, FontColor2);
   ObjectSet("Market_Price_Label", OBJPROP_CORNER, WhatCorner);
   ObjectSet("Market_Price_Label", OBJPROP_XDISTANCE, 1);
   ObjectSet("Market_Price_Label", OBJPROP_YDISTANCE, (FontSize+10));
   return(rates_total);
  }

Bogdan Caramalac
761
Bogdan Caramalac  

Well I didn't place the indicator, but shouldn't you write

 

 string Market_Price2 = DoubleToString(Ask,SymbolInfoInteger(Symbol(),SYMBOL_DIGITS));
 string Market_Price = DoubleToString(Bid,SymbolInfoInteger(Symbol(),SYMBOL_DIGITS));

 ?

To add comments, please log in or register