Do not post code that will not even compile.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
Always post all relevant code (using Code button) or attach the source file. Or use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
Do not post code that will not even compile.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
Always post all relevant code (using Code button) or attach the source file. Or use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
No you have not! You have only presented a summary of what you think is required. The code you have presented does not show the issue.
If you really want help, then show your actual code with the real issue.
If you don't want to show your actual code, then please use the built-in debugger in MetaEditor to debug your code and find the problem.
double x = 4.0; for ( loop ) { if(value > x) // <------<< when this is true { Print(value); // then only will this print . } Print(value); // <-------<< Print outside of an if statement will print the value every time the loop is run . :-) }
No you have not! You have only presented a summary of what you think is required. The code you have presented does not show the issue.
If you really want help, then show your actual code with the real issue.
If you don't want to show your actual code, then please use the built-in debugger in MetaEditor to debug your code and find the problem.
Fine I will post the real code if you guys insist.
#property strict void OnStart() { bool OnlyMarketWatch = true; double minimum_rate = 4.0; for(int pos=0;pos < SymbolsTotal(OnlyMarketWatch); pos++) { string symbol = SymbolName(pos,OnlyMarketWatch); double swap_long = MarketInfo(symbol,MODE_SWAPLONG); double swap_short = MarketInfo(symbol,MODE_SWAPSHORT); double swap_type = MarketInfo(symbol,MODE_SWAPTYPE); if(swap_type==0) { if(swap_long > minimum_rate) { Print(swap_long); } if (swap_short > minimum_rate) { Print(swap_short); } } } }
It seems that what is "wrong" is that you are not identifying your Prints, so you are unable to see which print belongs to what, leading to confusion.
And while your are it, best to print out the value of "minimum_rate" to make sure of its value, just as a debugging precaution.
EDIT: You might want to Print out the Symbol's name as well to help identify the values and make sure they are in agreement with the contract specifications.if(swap_long > minimum_rate) { Print( "swap_long: ", swap_long, ", minimum_rate: ", minimum_rate ); } if (swap_short > minimum_rate) { Print( "swap_short: ", swap_short, ", minimum_rate: ", minimum_rate ); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have a loop where I compare double values with another double like this:
The problem is the output looks like this:
Why does it print values that are not greater than x ?