-
Play videoPlease edit your post.
For large amounts of code, attach it Create a variable string candleColor;
if(Close[barInd]>Open[barInd]) candleColor = "White";
else candleColor = "Black";
FileWrite(fileh,
Symbol(),
Period(),
Open[barind],
High[barind],
Low[barind],
Close[barind],
candleColor
);Ternary Operator ?: - Operators - Language Basics - MQL4 Reference FileWrite(fileh,
Symbol(),
Period(),
Open[barind],
High[barind],
Low[barind],
Close[barind],
Close[barInd]>Open[barInd] ? "White" : "Black"
);
whroeder1:
Perfect! This works! Thanks a ton, whroeder1 !!
-
Please edit your post.
For large amounts of code, attach it Create a variable string candleColor;
if(Close[barInd]>Open[barInd]) candleColor = "White";
else candleColor = "Black";
FileWrite(fileh,
Symbol(),
Period(),
Open[barind],
High[barind],
Low[barind],
Close[barind],
candleColor
);Ternary Operator ?: - Operators - Language Basics - MQL4 Reference FileWrite(fileh,
Symbol(),
Period(),
Open[barind],
High[barind],
Low[barind],
Close[barind],
Close[barInd]>Open[barInd] ? "White" : "Black"
);
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,
The code I have, produces nicely the OHLC values as expected, but I also would like to add a new column giving me the Color of Candle (either "White", "Black", or "Doji").
I am trying to add it via an "IF" statement inside FileWrite function as follows:
Symbol(),
Period(),
Open[barind],
High[barind],
Low[barind],
Close[barind],
if (Close[barInd]>Open[barInd]) Print("White") // this is the "Color of Candle" example for a white (raising) candle...
);
Above giving syntax error (looks like the semicolons, etc, or even the whole structuring of "IF" statement is wrong and I simply can't figure out what route to take from here :(
Can someone please point me to the right direction here?
-ModestOne