You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
{
//---
ObjectCreate("SimultaneousReleaseIndex1",OBJ_LABEL,0,0,0);
ObjectSetString(0,"SimultaneousReleaseIndex1",OBJPROP_TEXT,"Four");
ObjectCreate("SimultaneousReleaseIndex2",OBJ_LABEL,0,0,0);
ObjectSetString(0,"SimultaneousReleaseIndex2",OBJPROP_TEXT,"44");
ObjectCreate("SimultaneousReleaseIndex3",OBJ_LABEL,0,0,0);
ObjectSetString(0,"SimultaneousReleaseIndex3",OBJPROP_TEXT,"Forty4");
ObjectCreate("SimultaneousReleaseIndex4",OBJ_LABEL,0,0,0);
ObjectSetString(0,"SimultaneousReleaseIndex4",OBJPROP_TEXT,".1234567890");
if(IsNumeric(ObjectGetString(0,"SimultaneousReleaseIndex1",OBJPROP_TEXT)))
Print("text1 is numeric");
if(IsNumeric(ObjectGetString(0,"SimultaneousReleaseIndex2",OBJPROP_TEXT)))
Print("text2 is numeric");
if(IsNumeric(ObjectGetString(0,"SimultaneousReleaseIndex3",OBJPROP_TEXT)))
Print("text3 is numeric");
if(IsNumeric(ObjectGetString(0,"SimultaneousReleaseIndex4",OBJPROP_TEXT)))
Print("text4 is numeric");
}
//---
bool IsNumeric(string text)
{
int length=StringLen(text);
for(int i=0;i<length;i++)
{
int char1=StringGetChar(text,i);
if((char1>47 && char1<58) || char1==46)
continue;
else
return(false);
}
return(true);
}
//+------------------------------------------------------------------+
Oh, look at me. I should have known. Thank you @whroeder1.
Another thing is how to enter negative numbers. The code needs to capture the negation sign (-) only at the beginning of the entry.
Moreover, in order to perfect the code. It needs to accept the negation symbol (-) even in the middle of numbers such as (45-20) and treat it as subtraction and evaluate and then use the code
The whole idea is to make OBJPROP_TEXT property of OBT_EDIT to accept economic calendar data and treat them as the numbers that they are. That is why an inbuilt function of IsNumeric is quite important to avoid writing unnecessarily large code for it.
Of course a period (.) should be numeric since (.) is regarded as the same thing with a period and zero (.0) which is in fact zero (0). Now I tried increasing the number of period (.....) and it is still recognizing it as numeric. We need the code for period (.) so as to eliminate additional period (....) once the first period has been cited in
Another thing is how to enter negative numbers. The code needs to capture the negation sign (-) only at the beginning of the entry.
Moreover, in order to perfect the code. It needs to accept the negation symbol (-) even in the middle of numbers such as (45-20) and treat it as subtraction and evaluate and then use the code
The whole idea is to make OBJPROP_TEXT property of OBT_EDIT to accept economic calendar data and treat them as the numbers that they are. That is why an inbuilt function of IsNumeric is quite important to avoid writing unnecessarily large code for it.
macpee:
Of course a period (.) should be numeric since (.) is regarded as the same thing with a period and zero (.0) which is in fact zero (0). Now I tried increasing the number of period (.....) and it is still recognizing it as numeric. We need the code for period (.) so as to eliminate additional period (....) once the first period has been cited in
Another thing is how to enter negative numbers. The code needs to capture the negation sign (-) only at the beginning of the entry.
Is there an echo in here?
Yep, that sort of thing.
You'd need to be careful about:
________________________________
By the way, I cannot find the list of the code (ASCII, I presume).
Go on, give it a go. I know you've been itching for a chance to hone your search skills.
________________________________
The whole idea is to make OBJPROP_TEXT property of OBT_EDIT to accept economic calendar data and treat them as the numbers that they are. That is why an inbuilt function of IsNumeric is quite important to avoid writing unnecessarily large code for it.
While I may have misunderstood your intention, if you want the user to enter dates into an edit box and then interpret them as datetimes (possibly not if you are interested in negative numbers), I'm not convinced this is the best approach for a number of reasons.
Is there an echo in here?
________________________________
Go on, give it a go. I know you've been itching for a chance to hone your search skills.
________________________________
While I may have misunderstood your intention, if you want the user to enter dates into a text box and then interpret them as datetimes (possibly not if you are interested in negative numbers), I'm not convinced this is the best approach for a number of reasons.
Actually the economic data in question do not include dates - just 'actual', 'forecast', 'previous' and possibly 'revised' data. Of course we also do not intend to enter symbols such as B(for billion), %(for percent) etc. Just pure real numbers without spaces. The idea is to calculate what I call "Simultaneous Release Index". It is meant to combine a set of economic data released simultaneously and see them as one datum. I would combine all 'actuals' as one 'actual', all 'forecasts' as one 'forecast', etc, in order to see the relationship between the combined 'actual' and combined 'forecast' etc.
So:
e.g.
{
StringReplace(text," ",NULL);
StringReplace(text,",",NULL);
int point_cnt = 0;
for(int i=StringLen(text)-1; i>=0; i--)
{
int this_char = StringGetChar(text,i);
if(this_char == '.')
{
point_cnt++;
if(point_cnt>1) return(false);
if(StringLen(text)<2) return(false);
}
else if(this_char == '+' || this_char == '-')
{
if(i>0) return(false);
}
else if(this_char < '0' || this_char > '9') return(false);
}
return(true);
}
If it returns true, you can cast the string as a number.
So:
e.g.
{
StringReplace(text," ",NULL);
StringReplace(text,",",NULL);
int point_cnt = 0;
for(int i=StringLen(text)-1; i>=0; i--)
{
int this_char = StringGetChar(text,i);
if(this_char == '.')
{
point_cnt++;
if(point_cnt>1) return(false);
if(StringLen(text)<2) return(false);
}
else if(this_char == '+' || this_char == '-')
{
if(i>0) return(false);
}
else if(this_char < '0' || this_char > '9') return(false);
}
return(true);
}
If it returns true, you can cast the string as a number.