Hi
I would like to add a Max Spread check function, and have the various ccypairs already set with the tolerance, so that I can just drop the EA on whatever pair and not worry about remembering to set it.
I tried to create a switch that would return either true or false that i can then just use in my order placement criteria, but I am not sure that I have done this correctly as MaxSpread keeps coming back as false.
In the example below AUDUSD is currently 16, which is less than 30 so I expected it to return true.
What did I do wrong? Or is there a better way to do this?
switch(bool) ??
switch (CcyPair)
bool MaxSpread; <-- defaults to zero/false // irrevalent //Spread Check - to make sure the spread has not widened to far. // irrevalent int CcyPair = 0; // irrevalent if (Symbol() =="AUDUSD") CcyPair = 1; // irrevalent if (Symbol() =="GBPUSD") CcyPair = 2; // irrevalent if (Symbol() =="EURUSD") CcyPair = 3; // irrevalent if (Symbol() =="USDCAD") CcyPair = 4; switch (MaxSpread) <-- switch(0) no case matches switch exits { // irrevalent case 1: MaxSpread = MarketInfo(Symbol(),MODE_SPREAD) < 30; break; // irrevalent case 2: MaxSpread = MarketInfo(Symbol(),MODE_SPREAD)< 50; break; }
Hi
I would like to add a Max Spread check function, and have the various ccypairs already set with the tolerance, so that I can just drop the EA on whatever pair and not worry about remembering to set it.
I tried to create a switch that would return either true or false that i can then just use in my order placement criteria, but I am not sure that I have done this correctly as MaxSpread keeps coming back as false.
In the example below AUDUSD is currently 16, which is less than 30 so I expected it to return true.
What did I do wrong? Or is there a better way to do this?
thanks
Simon
extern double MaxSpreadPips = 4.5; double SymSpread; //---------------------------------------------------------------------------------------------------------- int start() //---------------------------------------------------------------------------------------------------------- { if(Digits==3){SymSpread=(Ask-Bid)*100;} if(Digits==5){SymSpread=(Ask-Bid)*10000;} } //---------------------------------------------------------------------------------------------------------- int OpenOrders(int Direction) // //---------------------------------------------------------------------------------------------------------- { if(SymSpread>MaxSpreadPips){Print("MaxSpreadPips Triggered"); return(0);} }
This is just one currency, do you mean to monitor multiple currencies from one chart? like EURUSD?
This is just one currency, do you mean to monitor multiple currencies from one chart? like EURUSD?
Thanks - that's pretty much what I was going to do originally. But then I thought I could have a list of currencies and the max spreads for each, that would be checked. that way I wouldn't need to amend the etern variable each time. I am now thinking the external check is probably the most sensible, but I still want to work out how to do the switch method, just to increase my coding skills.
Thanks - that's pretty much what I was going to do originally. But then I thought I could have a list of currencies and the max spreads for each, that would be checked. that way I wouldn't need to amend the etern variable each time. I am now thinking the external check is probably the most sensible, but I still want to work out how to do the switch method, just to increase my coding skills.
Thanks - that's pretty much what I was going to do originally. But then I thought I could have a list of currencies and the max spreads for each, that would be checked. that way I wouldn't need to amend the etern variable each time. I am now thinking the external check is probably the most sensible, but I still want to work out how to do the switch method, just to increase my coding skills.
Your currency switch may be useful to use the right MaxSpread depending on the Symbol?
Read all the posts not just the last one . . .
thanks - I will come back to this - just need to fix another issue first so that I can start running some tests.
- 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 would like to add a Max Spread check function, and have the various ccypairs already set with the tolerance, so that I can just drop the EA on whatever pair and not worry about remembering to set it.
I tried to create a switch that would return either true or false that i can then just use in my order placement criteria, but I am not sure that I have done this correctly as MaxSpread keeps coming back as false.
In the example below AUDUSD is currently 16, which is less than 30 so I expected it to return true.
What did I do wrong? Or is there a better way to do this?
thanks
Simon