Spread is in points, not pips
peterhw1: The broker appears to suggest I have the decimal point in the wrong place (should be 3 pips)
Initializing an array with constants can be done at compile time string My_Symbols[]={"", "AUDUSD", "EURGBP", "EURUSD", "GBPUSD", "USDCAD" "USDCHF", "USDJPY" };
for (int My_Index=1; My_Index < 10; My_Index++)
Also get in the habit of using zero based indexes. It will help you in the future. Don't hard code numbers ArraySize(My_Symbols).- Mode_spread returns the number points (1, 2, 3,...) To display it as a price delta you multiply by that currency's mode_point.
DoubleToString(My_Spread,Digits)
Digits only applies to the current chart pair. You need the currency's mode_digits.
Many thanks for response.
Point 1 understood - very usefuk
Point 2 understood again and appreciate
Points 3 & 4 understand just took a short cut for example
Have modified as suggested (I think) but still get 'fixed' spread on new broker - could this be possible ?
string myc = ""; double My_Spread = 0; double My_Mode_Pt = 0; string My_Symbols[]={ "AUDUSD", "EURGBP", "EURUSD", "GBPUSD", "USDCAD","USDCHF", "USDJPY" }; string My_Symbol= ""; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { myc = "Good Morning"; Comment(myc); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } void OnTick() { //--- myc = "Testing Spread"; myc = myc + "\nArraySize(My_Symbols) = "+IntegerToString(ArraySize(My_Symbols)); for (int My_Index=0; My_Index < ArraySize(My_Symbols); My_Index++) { My_Symbol = My_Symbols[My_Index]; My_Spread = MarketInfo(My_Symbol,MODE_SPREAD); My_Mode_Pt = MarketInfo(My_Symbol,MODE_POINT); myc = myc + "\nMy_Index = "+IntegerToString(My_Index) + " My_Symbol = "+My_Symbol; myc = myc + " My_Mode_Pt = "+DoubleToString(My_Mode_Pt,5)+" Spread = "+DoubleToString(My_Spread,5); } Comment(myc); return; }
peterhw1: Have modified as suggested (I think) but still get 'fixed' spread on new broker - could this be possible ?
- It's possible if the broker only uses fixed spreads.
- Your original code works as posted
- Your modified code works as posted
- Are the symbols exactly what you have in your market watch?
// Broker's use a variety of nameing patterns: EURUSD, EURUSDm, EURUSDi // "EURUSD.", "EURUSD..", "EUR.USD", "EUR/USD", "EURUSD.stp", EURUSDct, // "EURUSD.G", "EURUSD+", EURUSDpro at least.
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
I thought I'd try a new broker and wanted to check out spreads using the code below.
Running the EA showed figures (screenshot below) which don't seem realistic and they don't change (as on another broker where the spreads are always changing)
The broker doesn't appear to even understand the problem (probably speaks for itself!). The broker appears to suggest I have the decimal point in the wrong place (should be 3 pips)
Obviously the EA sort of works - it creates the comment - but the Market Info does appear to generate incorrect data
Any ideas ?