SendMail() not applying new lines.

 

Morning,

So I have a diagnostics email set up which contains the data on all the criteria needed to execute a position, it's to ensure that the EA is meeting all of the criteria and using ternary to give it a "PASS" or a "FAIL". 

It's pretty neat if I do say so myself.! 

For some reason, MQL4 has decided to stop implementing a new line for each line of data, despite applying the:

+"\n"+

function, once it get's part way down the email. 

The function is below.

Disregard the data itself, this was just inserted so anyone on here can replicate the issue, without me needing to declare every single variable which will be cumbersome. However, the structure of the function is the same. 

I don't see why it's not applying a new line beyond the "Account Risk Percentage". 

int a = 1;
int b = 2;

SendMail(StringFormat("<Company Name Ommited> | Diagnostics",0),"This is your Diagnostic Data for Failed Position Openings"+
"\n"+
"\n"+
(a > b ? "PASS " : "FAIL ")+"| Partial Close"+ 
"\n"+
(a <= a ? "PASS " : "FAIL ")+"| Spread "+
"\n"+
((a / b <= 3) || (a /b <= 4) ? "PASS " : "FAIL ")+"| Initial Retracement "+
"\n"+
(((a / b <= 4) && (a / b > 0)) || ((a / b <= 4) && (a/ b > 0)) || ((a / b <= 4) && (a / b > 0)) || ((a / b <= 4) && (a / b > 0)) ? "PASS " : "FAIL ")+"| HammerHandlePct "+
"\n"+
(((a / b <= hammerHeadPct) && (a / b > 0)) || ((a / b <= 4) && (a / b > 0)) || ((a / b <= 4) && (b / a > 0)) || ((a / b <= 4) && (a / b > 0)) ? "PASS " : "FAIL " )+"| HammerHeadPct "+
"\n"+
StringFormat("PASS | Momentum Fast: %d %0.5f ",a, b)+
"\n"+
StringFormat("PASS | Momentum Slow: %d %0.5f ",a, b)+
"\n"+
StringFormat("PASS | Trend Fast: %d %0.5f ",a, b)+
"\n"+
StringFormat("PASS | Trend Slow: %d %0.5f ",a, b)+
"\n"+
((AccountEquity() / marginRequired * 100 >= brokerMarginLevel ? "PASS " : "FAIL ")+"| Margin Requirement.")+
"\n"+
("PASS | Account Risk Percentage")+ ////beyond this point, no new line is being implemented
"\n"+
(((a >= b && a < b) ? "PASS " : "FAIL " )+StringFormat("| Correlation of Determination (r-Squared): %0.0f%%", a * 100))+ 
"\n"+
((((a > b && a <= b) || (a >=  b && a < b)) ? "PASS " : "FAIL ")+StringFormat("| Correlation Coefficient %0.2f ",a))+
"\n"+
((a <= b ? "PASS " : "FAIL ")+"| Standard Deviation: "+DoubleToString(NormalizeDouble(a / Point,0),0)));

The resulting email is also included.

Anyone have any ideas as to why this is happening?

All the best.

Files:
 
  1.                               (a <= a ? "PASS " : "FAIL ")+"| Spread "+

    That will always be true.

  2.                               (((a / b <= 4) && (a / b > 0)) || ((a / b <= 4) && (a/ b > 0)) || ((a / b <= 4) && (a / b > 0)) || ((a / b <= 4) && (a / b > 0)) ? "PASS " : "FAIL ")+"| HammerHandlePct "+
    

    Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it.

  3. Simplify your code:

       string parClo= (a > b ? "PASS " : "FAIL ")+"| Partial Close";
       ⋮
       bool isHandle=    ((a / b <= 4) && (a / b > 0)) 
                      || ((a / b <= 4) && (a/ b > 0)) 
                      || ((a / b <= 4) && (a / b > 0)) 
                      || ((a / b <= 4) && (a / b > 0));
       string pfHandle   = isHandle ? "PASS " : "FAIL ")+"| HammerHandlePct "+
       
       bool isHead=   ((a / b <= hammerHeadPct) && (a / b > 0)) 
                   || ((a / b <= 4) && (a / b > 0)) 
                   || ((a / b <= 4) && (b / a > 0)) 
                   || ((a / b <= 4) && (a / b > 0));
       string pfHead= (isHead ? "PASS " : "FAIL " )+"| HammerHeadPct "+
       ⋮
    SendMail(StringFormat("<Company Name Ommited> | Diagnostics",0),"This is your Diagnostic Data for Failed Position Openings"+
                                  "\n"+
                                  "\n"+parClo+
                                  ⋮

    Now you can use the tester and print the values to SendMail and perhaps, find out why.

 
William Roeder #:
  1. That will always be true.

  2. Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it.

  3. Simplify your code:

    Now you can use the tester and print the values to SendMail and perhaps, find out why.

As advised by your good self, and to help others with similar issues;

Have to say, it's a much simpler, "cleaner" way of setting it all out :) 


				string partClo                 	=     (breakeven > stopLossPoints ? "Pass" : "FAIL")+"| Partial Close";
                                 
                             	string isSpread                	=     (spread <= MaxSpread ? "PASS" : "FAIL")+"| Spread";
                              
                             	bool   isHammerHeadPct         	=     ((bullHammerHead / bullRetracementCandle <= hammerHeadPct) && (bullHammerHead / bullRetracementCandle > 0))
                             
                                                            	||    ((bearHammerHead / bullRetracementCandle <= hammerHeadPct) && (bearHammerHead / bullRetracementCandle > 0))
                                                            
                                                            	||    ((bullHammerHead / bearRetracementCandle <= hammerHeadPct) && (bullHammerHead / bearRetracementCandle > 0))
                                                            
                                                            	||    ((bearHammerHead / bearRetracementCandle <= hammerHeadPct) && (bearHammerHead / bearRetracementCandle > 0));
                     
                             	string pfHammerHeadPct         	=     (isHammerHeadPct    ? "PASS " : "FAIL ")+"| HammerHandlePct";
                              
                             	bool   isHammerHandlePct       	=     ((bullHammerHead / bullHammerHandle <= hammerHandlePct) && (bullHammerHead / bullHammerHandle > 0))
                             
                                                            	||    ((bearHammerHead / bullHammerHandleInv <= hammerHandlePct) && (bearHammerHead / bullHammerHandleInv > 0)) 
                                                            
                                                            	||    ((bearHammerHead / bearHammerHandle <= hammerHandlePct) && (bearHammerHead / bearHammerHandle > 0)) 
                                                            
                                                            	||    ((bullHammerHead / bearHammerHandleInv <= hammerHandlePct) && (bullHammerHead / bearHammerHandleInv > 0));
                                                            
                             	string pfIsHammerHandlePct     	=     (isHammerHandlePct ? "PASS " : "FAIL ")+"| HammerHandlePct ";
                              
                             	bool   isInitialTrend          	=     (initialTrendBullCandle / bearRetracementCandle <= retracePercentage) 
                              
                                                            	||    (initialTrendBearCandle / bullRetracementCandle <= retracePercentage); 
                                                            
                             	string pfIsInitialTrent        	=     isInitialTrend ? "PASS" : "FAIL" +"| Initial Retracement";         
                              
                             	string isRSquared              	=     StringFormat((rSquared >= minRSquared && rSquared < maxRSquared ? "PASS " : "FAIL " )+"| R-Squared: %0.0f%%", rSquared * 100); 

                             	string isStandardDeviation     	=     StringFormat(yourStandardDeviation <= maxStandardDeviation ? "PASS " : "FAIL "+"| Standard Deviation: %d",sqrtEyMinusAveragePow2 / Point);

                             	string isAccountEquity         	=     ((AccountEquity() / marginRequired * 100 >= brokerMarginLevel ? "PASS " : "FAIL ")+"| Margin Requirement.");
                              
                             	string isMomFast               	=     StringFormat("PASS | Momentum Fast: %d %0.5f ",Period_MomentumFast, momentumFast);
                              
                             	string isMomSlow               	=     StringFormat("PASS | Momentum Slow: %d %0.5f ",Period_MomentumSlow, momentumSlow);
                              
                             	string isTrendFast             	=     StringFormat("PASS | Trend Fast: %d %0.5f ",Period_TrendFast, trendFast);
                              
                             	string isTrendSlow             	=     StringFormat("PASS | Trend Slow: %d %0.5f ",Period_TrendSlow, trendSlow);
                              
                             	SendMail(StringFormat("xxxxxx | Diagnostics %s %d:00 GMT",symbol, hourOfDay + GMTAdjustment),"This is your Diagnostic Data for Failed Position Openings"+
                             	"\n"+
                             	"\n"+partClo+
                             	"\n"+isSpread+
                             	"\n"+pfHammerHeadPct+
                             	"\n"+pfIsHammerHandlePct+
                             	"\n"+pfIsInitialTrent+
                             	"\n"+isRSquared+
                             	"\n"+isStandardDeviation+
                             	"\n"+isAccountEquity+
                             	"\n"+isMomFast+
                             	"\n"+isMomSlow+
                             	"\n"+isTrendFast+
                             	"\n"+isTrendSlow);
Reason: