Why doesn't this EA only print changing Bids? - page 2

 
nadiawicket:

AWESOME!!!!! That works!!!

Its all just 0 after Digits; why use 8? Working without it, but I'd like to know why you prefer 8

Its from documentation not me. 8 is for any two doubles(its calculated to be minimum diffeeence allowed for double size). 
But for 2 prices you can use _Point as Ernst suggested which is the smallest difference for forex prices.
Its working without it because the min difference for two forex bids is Point which is larger then 8 decimals
 
//+------------------------------------------------------------------+
//|                                                       Change.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

double NormalizePrice(double x)
  {
   double TickSize=MarketInfo(Symbol(),MODE_TICKSIZE);
   return(MathRound(x/TickSize)*TickSize);
  }

double BidPrevious;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   if(NormalizePrice(Bid-BidPrevious)!=0)
     {
      Print(Bid);
      BidPrevious=Bid;  // only when printed
     }

  }
//+------------------------------------------------------------------+

Like to use that function instead as I heard horror stories about Normalize Double

 
Amir Yacoby:
Its from documentation not me. 8 is for any two doubles(its calculated to be minimum diffeeence allowed for double size). 
But for 2 prices you can use _Point as Ernst suggested which is the smallest difference for forex prices.
Its working without it because the min difference for two forex bids is Point which is larger then 8 decimals
if(NormalizeDouble(Bid-BidPrevious,8)!=0)
  {
     Print(Bid);
     BidPrevious=Bid;  // only when printed

   }


I realize Ernst suggested comparing to _Point instead of 0 however I don't think I'm understanding your reasoning about the usage of _Point in your version of the solution or in any of the solutions in this thread; Where would you suggest using _Point in there? Instead of 0 in order to have a larger reference to compare so as to keep a more noticeable bias or something along those lines? You really think its going to make a difference?


 
nadiawicket:
if(NormalizeDouble(Bid-BidPrevious,8)!=0)
  {
     Print(Bid);
     BidPrevious=Bid;  // only when printed

   }


I realize Ernst suggested comparing to _Point instead of 0 however I don't think I'm understanding your reasoning about the usage of _Point in your version of the solution or in any of the solutions in this thread; Where would you suggest using _Point in there? Instead of 0 in order to have a larger reference to compare so as to keep a more noticeable bias or something along those lines? You really think its going to make a difference?


Normalize to tick size as you did is better then point. 
 
iRick:

Try: Print(DoubleToString(Bid));

Apparently something went wrong when I tried this approach on my own first before posting and after trying this approach again I can confirm it was in fact also a working solution. Many thanks
 
Ernst Van Der Merwe:

Apparently I was also incorrectly implementing your solution as I can now confirm its also a working fix. THX

Should've posted my incorrect code so as to be clear what was doing wrong and be further educated

Reason: