Try
int s=(int)(MathAbs(NormalizeDouble(priceH,_Digits)-NormalizeDouble(priceL,_Digits))/_Point);
possible loss of data due to type conversion
i have a couple days to google with this problem but no to avail. Anybody help to correct my own code. thanks in advance!
Hi
The result of your function is a double but your casting it to an int implicitly.
You can fix it this way:
double priceS(double priceH,double priceL) { double s=MathAbs(NormalizeDouble(priceH,_Digits)-NormalizeDouble(priceL,_Digits))/_Point; return(s); }
or
int priceS(double priceH,double priceL) { int s = (int)(MathAbs(NormalizeDouble(priceH,_Digits)-NormalizeDouble(priceL,_Digits))/_Point); return(s); }
Try
same error.
Hi
The result of your function is a double but your casting it to an int implicitly.
You can fix it this way:
or
same error
Hi
The result of your function is a double but your casting it to an int implicitly.
You can fix it this way:
or
when I change to double, it creates 49 errors. but at this time of writing i try to fix affected lines. i post it again if error is continue. tnx.
Hi
The result of your function is a double but your casting it to an int implicitly.
You can fix it this way:
or
when I change affected lines, it result back to error. the issue is unresolved. any ideas why i encountered that error? is there a solution of getting "Difference" between two Price involved in my coding and produce int result?
when I change affected lines, it result back to error. the issue is unresolved. any ideas why i encountered that error? is there a solution of getting "Difference" between two Price involved in my coding and produce int result?
Solutions given to you in posts #1 and #2 should work.
If not, please show more of your code.
edit:
personally, I do prefer this...
int priceS(double priceH,double priceL) { int s = int(MathAbs(NormalizeDouble(priceH-priceL,_Digits)/_Point)); return(s); }
Solutions given to you in posts #1 and #2 should work.
If not, please show more of your code.
edit:
personally, I do prefer this...
//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2018, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ int iMN1C1us=0, iMN1C1rb=0, iMN1C1ls=0, iMN1C1cl=0; int priceS(double priceH,double priceL) { int s = MathAbs(NormalizeDouble(priceH,_Digits)-NormalizeDouble(priceL,_Digits))/_Point; return(s); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { if(iOpen(Symbol(),PERIOD_MN1,1)<iClose(Symbol(),PERIOD_MN1,1)) { //Pd1T="Bl"; iMN1C1us=priceS(iHigh(Symbol(),PERIOD_MN1,1),iClose(Symbol(),PERIOD_MN1,1)); iMN1C1rb=priceS(iClose(Symbol(),PERIOD_MN1,1),iOpen(Symbol(),PERIOD_MN1,1)); iMN1C1ls=priceS(iOpen(Symbol(),PERIOD_MN1,1),iLow(Symbol(),PERIOD_MN1,1)); iMN1C1cl=priceS(iHigh(Symbol(),PERIOD_MN1,1),iLow(Symbol(),PERIOD_MN1,1)); } else if(iOpen(Symbol(),PERIOD_MN1,1)>iClose(Symbol(),PERIOD_MN1,1)) { //Pd1T="Br"; iMN1C1us=priceS(iHigh(Symbol(),PERIOD_MN1,1),iOpen(Symbol(),PERIOD_MN1,1)); iMN1C1rb=priceS(iOpen(Symbol(),PERIOD_MN1,1),iClose(Symbol(),PERIOD_MN1,1)); iMN1C1ls=priceS(iClose(Symbol(),PERIOD_MN1,1),iLow(Symbol(),PERIOD_MN1,1)); iMN1C1cl=priceS(iHigh(Symbol(),PERIOD_MN1,1),iLow(Symbol(),PERIOD_MN1,1)); } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnTick() { } //+------------------------------------------------------------------+
please consider the algo of the program. it result same errors " possible loss of data due to type conversion "
"
please consider the algo of the program. it result same errors " possible loss of data due to type conversion "
"
Of course.
Because it doesn't contain the fix recommended in posts #1 and #2.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
possible loss of data due to type conversion (MQL5)
i have a couple days to google with this problem but no to avail. Anybody help to correct my own code. thanks in advance!