Download MetaTrader 5

Two problems with EA, IsConnected() - (SOLVED) and NormalizeDouble

To add comments, please log in or register
GrumpyDuckMan
564
GrumpyDuckMan  

Hello everyone,

I have internet connection problems in my area, so I am interested in IsConnected(). I was trying to test this today, but after disconnecting my WiFi and cables from internet and restarting my computer. MetaTrader was telling me it is still connected. Should I add a delay before EA starts again? 

   if(!IsConnected())
     {
      Alert("No connection!");
      return;
     }

I don't understand why all variables aren't debugging at four decimal places. I noticed some are only showing three decimal places, not the four decimal places expected.

void ReadAppliedIndictors(){
double
       StochMain=iStochastic(NULL,TIMEFRAME,SIGNAL,MAIN,Slowing,MODE_SMA,0,MODE_MAIN,0),ValueStochMain=NormalizeDouble((StochMain),4),
       StochSignal=iStochastic(NULL,TIMEFRAME,SIGNAL,MAIN,Slowing,MODE_SMA,0,MODE_SIGNAL,0),ValueStochSignal=NormalizeDouble((StochSignal),4),
       READplus=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_PLUSDI,0),PlusADX=NormalizeDouble((READplus),4),
       READminus=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_MINUSDI,0),MinusADX=NormalizeDouble((READminus),4),
       CurrentADX=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_MAIN,0),ADX=NormalizeDouble((CurrentADX),4),
       CurrentRSI=iRSI(NULL,TIMEFRAME,8,PRICE_OPEN,0),RSIvalue=NormalizeDouble((CurrentRSI),4),
       CurrentiMA=iMA(NULL,TIMEFRAME,8,3,MODE_EMA,PRICE_OPEN,0),IMA=NormalizeDouble((CurrentiMA),4),
       iMoneyFlow=iMFI(NULL,TIMEFRAME,8,0),MoneyFlow=NormalizeDouble((iMoneyFlow),4);}
Carl Schreiber
Moderator
7813
Carl Schreiber  
  1. IsConnected(): check when the status at the right site of the bottom line changes.
  2. Decimals: Try to understand the indicators you request! E.g. iStochastic varies between +100 and 0! 4 decimals simply do not make sense!
whroeder1
16764
whroeder1  
  1. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
  2. GrumpyDuckMan: I don't understand why all variables aren't debugging at four decimal places. I noticed some are only showing three decimal places, not the four decimal places expected.
    If you want to see 4 places, print them out to 4, not normalize them.
DoubleToString - Conversion Functions - MQL4 Reference
DoubleToString - Conversion Functions - MQL4 Reference
  • docs.mql4.com
DoubleToString - Conversion Functions - MQL4 Reference
GrumpyDuckMan
564
GrumpyDuckMan  

Hello again,

I am trying to test the strengths versus weakness of NULL pair.

GrumpyDuckMan
564
GrumpyDuckMan  

Hello everyone,

my first attempt at using DoubletoString. I am not sure this code is written correctly.

//+------------------------------------------------------------------+
int A(){
   double StochMain=iStochastic(NULL,TIMEFRAME,SIGNAL,MAIN,Slowing,MODE_SMA,0,MODE_MAIN,0);
   string sm=DoubleToString(StochMain,0);
   return(SM);}
//+------------------------------------------------------------------+
int B(){
   double StochSignal=iStochastic(NULL,TIMEFRAME,SIGNAL,MAIN,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
   string ss=DoubleToString(StochSignal,0);
   return(SS);}
//+------------------------------------------------------------------+
int C(){
   double READplus=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_PLUSDI,0);
   string rp=DoubleToString(READplus,0);
   return(RP);}
//+------------------------------------------------------------------+
int D(){   
   double READminus=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_MINUSDI,0);
   string rm=DoubleToString(READminus,0);
   return(RM);}
//+------------------------------------------------------------------+   
int E(){   
   double CurrentADX=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_MAIN,0);
   string ca=DoubleToString(CurrentADX,0);
   return(AM);}
//+------------------------------------------------------------------+
int F(){
   double CurrentRSI=iRSI(NULL,TIMEFRAME,8,PRICE_OPEN,0);
   string cr=DoubleToString(CurrentRSI,0);
   return(RSI);}
//+------------------------------------------------------------------+
int G(){
   double CurrentiMA=iMA(NULL,TIMEFRAME,8,3,MODE_EMA,PRICE_OPEN,0);
   string ci=DoubleToString(CurrentiMA,0);
   return (IMA);}
//+------------------------------------------------------------------+
int H(){
   double iMoneyFlow=iMFI(NULL,TIMEFRAME,8,0);
   string mf=DoubleToString(iMoneyFlow,0);
   return(MF);}
//+------------------------------------------------------------------+
whroeder1
16764
whroeder1  
GrumpyDuckMan: my first attempt at using DoubletoString. I am not sure this code is written correctly.

Your functions are declared to return a int not a string.

GrumpyDuckMan
564
GrumpyDuckMan  
whroeder1:

Your functions are declared to return a int not a string.

I was fairly sure it was incorrectly coded, on the other hand all returns equal closely to values I expected them to be.

I'm experiencing a problem with return values for (RSI) and (IMA). Both of these appear to be returning a true/false indication and not a true value.

GrumpyDuckMan
564
GrumpyDuckMan  
//+------------------------------------------------------------------+
string A(){
   double StochMain=iStochastic(NULL,TIMEFRAME,SIGNAL,MAIN,Slowing,MODE_SMA,0,MODE_MAIN,0);
   SM=DoubleToString(StochMain,0);
   return(SM);}//Main_Stoch_Return
//+------------------------------------------------------------------+
string B(){
   double StochSignal=iStochastic(NULL,TIMEFRAME,SIGNAL,MAIN,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
   SS=DoubleToString(StochSignal,0);
   return(SS);}//Signal_Stoch_Return
//+------------------------------------------------------------------+
string C(){
   double READplus=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_PLUSDI,0);
   RP=DoubleToString(READplus,0);
   return(RP);}//ADX_Plus_Return
//+------------------------------------------------------------------+
string D(){   
   double READminus=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_MINUSDI,0);
   RM=DoubleToString(READminus,0);
   return(RM);}//ADX_Minus_Return
//+------------------------------------------------------------------+   
string E(){   
   double CurrentADX=iADX(NULL,TIMEFRAME,8,PRICE_OPEN,MODE_MAIN,0);
   AM=DoubleToString(CurrentADX,0);
   return(AM);}//ADX_adx_Return
//+------------------------------------------------------------------+
string F(){
   double CurrentRSI=iRSI(NULL,TIMEFRAME,8,PRICE_OPEN,0);
   RSI=DoubleToString(CurrentRSI,0);
   return(RSI);}//RSI_Return
//+------------------------------------------------------------------+
string G(){
   double CurrentiMA=iMA(NULL,TIMEFRAME,8,0,MODE_SMMA,PRICE_OPEN,0);
   IMA=DoubleToString(CurrentiMA,0);
   return (IMA);}//MA_Return
//+------------------------------------------------------------------+
string H(){
   double iMoneyFlow=iMFI(NULL,TIMEFRAME,8,0);
   MF=DoubleToString(iMoneyFlow,0);
   return(MF);
   }//Money_flow_Return
//+------------------------------------------------------------------+
To add comments, please log in or register