anuj71:
Can we do like this?
Output should be :
why don't you just try it...
Check docmentation before ask anything in forum.
https://www.mql5.com/en/docs/basis/types

Documentation on MQL5: Language Basics / Data Types
- www.mql5.com
Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
anuj71 #: I tried and not working. That is the reason behind i am asking here. Is it possible to convert bool to string?
Did the compiler not throw and error for your code? It should have!
Please learn to reference the online Book and Documentation
bool bTakeProfit = true; // it is "true" and not "TRUE" string sTakeProfit = (string) bTakeProfit; // explicit typecasting to a string // The following will all output "true" ... Print( bTakeProfit ); // Method 1 ... implicit typecasting Print( (string) bTakeProfit ); // Method 2 ... explicit typecasting to a string Print( sTakeProfit ); // Method 3 ... variable is already a string

MQL5 programming for traders - MetaTrader 5 algorithmic/automatic trading language manual
- www.mql5.com
MQL5 programming for traders - MetaTrader 5 algorithmic/automatic trading language manual
string result = (string) flag; // simplified - explicit typecasting to a string
Fernando Carreiro #:
Did the compiler not throw and error for your code? It should have!
Did the compiler not throw and error for your code? It should have!
Error : 'booltostring' - function not defined output.mq4 31 7
For me, it giving values like 0 and 1. 0 For false and 1 for True.
Fernando Carreiro #:
string result = (string) flag; // simplified - explicit typecasting to a string
string result = (string) flag; // simplified - explicit typecasting to a string
bool takeprofit = FALSE;
Comment(
"\n :: bool :", takeprofit,
"\n :: Bool string :", (string) takeprofit,
"\n :: -------------------------------"
);
Both returning values 0 not "FALSE".
bool takeprofit = true; Comment( "\n :: bool :", takeprofit, "\n :: Bool string :", (string) takeprofit, "\n :: -------------------------------" );This still return value 1 instead of word/string "true"

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
Can we do like this?
Output should be :