Sneck55: My EA has different types of order and with some of them, if I specify a colour in OrderSend() and OrderClose(), it creates a big mess on the chart with repeated trades opening and closing. Therefore for some orders I need a colour and for others I need nothing. When I compile I am getting the message "implicit conversion from 'string' to 'number'". Could somebody tell me how to use a variable to specify the colour to use, or none, or alternatively is there a table where all the colours have numbers and I can specify it as an integer?
Firstly, use the "SRC" button when adding source code and secondly, colours are "color" and not "string".
You can also use inline Ternary Operator instead of the "if" function for assigning values to a variable.
You should also use the Order Close Price instead of Bid or Ask, when closing an Order, irrespective of it being a buy or a sell order.
As for the list of colours, they are available in the documentation as the standard Web Colors.color EntryExitColour;
EntryExitColour = (Type == 26) ? clrNone : clrAquamarine;
if( OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, EntryExitColour ) )
{
//..code etc
}
![Ternary Operator ?: - Operators - Language Basics - MQL4 Reference Ternary Operator ?: - Operators - Language Basics - MQL4 Reference](https://c.mql5.com/36/12/ternary-operator-operators-language.png)
Ternary Operator ?: - Operators - Language Basics - MQL4 Reference
- docs.mql4.com
Ternary Operator ?: - Operators - Language Basics - MQL4 Reference
Fernando Carreiro:
Firstly, use the "SRC" button when adding source code and secondly, colours are "color" and not "string".
You can also use inline Ternary Operator instead of the "if" function for assigning values to a variable.
You should also use the Order Close Price instead of Bid or Ask, when closing an Order, irrespective of it being a buy or a sell order.
Thank you Fernando
Firstly, use the "SRC" button when adding source code and secondly, colours are "color" and not "string".
You can also use inline Ternary Operator instead of the "if" function for assigning values to a variable.
You should also use the Order Close Price instead of Bid or Ask, when closing an Order, irrespective of it being a buy or a sell order.
As for the list of colours, they are available in the documentation as the standard Web Colors.color EntryExitColour;
EntryExitColour = (Type == 26) ? clrNone : clrAquamarine;
if( OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, EntryExitColour ) )
{
//..code etc
}
Sneck55:
Thank you Fernando
Could you please tell me where the SRC button is as I can't find it in the menus or toolbar customiser and it doesn't appear to have been included with Help.
Thank you Fernando
Are you blind? It's not in "menus or toolbars," therefor is won't be in the help. We're talking about this forum. |
|
whroeder1:
Kindly don't be rude whroeder1. Therefore has an e on the end. I asked a simple question and the previous comment did not make that clear
Are you blind? It's not in "menus or toolbars," therefor is won't be in the help. We're talking about this forum. |
|
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello,
My EA has different types of order and with some of them, if I specify a colour in OrderSend() and OrderClose(), it creates a big mess on the chart with repeated trades opening and closing. Therefore for some orders I need a colour and for others I need nothing.
My code is as follows:
string EntryExitColour;
if(Type == 26) EntryExitColour = "CLR_NONE"; else EntryExitColour = "clrAquamarine";
if(OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,EntryExitColour))
{
..code etc
}
When I compile I am getting the message "implicit conversion from 'string' to 'number'". Could somebody tell me how to use a variable to specify the colour to use, or none, or alternatively is there a table where all the colours have numbers and I can specify it as an integer?
Thanks.