I can't figure this out

 

Hi


I'm trying to make my spread filter work again, as it was working perfectly before and now it isn't and for the life of me I can't figure out why.


In my trading routine I check for low spreads :

double maxSpread = 0.4;
int spread = SymbolInfoInteger(pair,SYMBOL_SPREAD);

if (spread <= maxSpread*10)

        Open_Order();

now as I said it was working fine.


now I can't make it work. if I set maxSpread to 100 it opens all orders; but If I set it to 1 it stops opening orders

1 should be plenty enough on an IC Market demo account

I even print out the values in my routine :

   Print("spread ",spread);
   Print("Parameters.maxSpread*10 ",Parameters.maxSpread*10);

and output should work :

2022.06.04 17:14:42.616 2022.01.11 17:10:08   spread = 1
2022.06.04 17:14:42.616 2022.01.11 17:10:08   Parameters.maxSpread*10 = 4.0
2022.06.04 17:14:42.616 2022.01.11 17:10:08   spread = 0
2022.06.04 17:14:42.616 2022.01.11 17:10:08   Parameters.maxSpread*10 = 4.0
2022.06.04 17:14:42.616 2022.01.11 17:10:08   spread = 2
2022.06.04 17:14:42.616 2022.01.11 17:10:08   Parameters.maxSpread*10 = 4.0
2022.06.04 17:14:42.616 2022.01.11 17:10:09   spread = 1
2022.06.04 17:14:42.616 2022.01.11 17:10:09   Parameters.maxSpread*10 = 4.0

but it doesn't. it's a simple "<=" that doesn't work. I don't understand


EDIT : i think I have a problem somewhere else. because If I bypass my other checks(), the spread is not an issue anymore

sorry about that guys, I was too hasty to seek for help

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Account Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Try changing   int spread   to   double spread

Check that the spread values match those in the symbol window.  Select spread option in the symbol window if it's not visible.

 
I had the same problem when using SymbolInfoInteger function to get the spread vlaue. Use iSpread function instead
Reason: