stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Need help with adding MaxSpread condition
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3152
Page 1 of 1
Author:  ThaiGuy [ Sat Sep 14, 2013 9:57 pm ]
Post subject:  Need help with adding MaxSpread condition

I'm testing this EA I found somewhere, and would love to use (test) it for metals and indices, however... for example Gold (xauusd) sometimes have spreads of 25 pips and sometimes even above 60 pips.

So I was wondering how I can have a filter added to this EA for only open any trade when the current spread is for example $MaxSpread=30.

A modified code will be nice, however.. I also would like to learn from it, so if someone can also provide me with an explanation I would be really happy :)

[code]
/
[/code]

Cheers,
[i][size=100]TG[/size][/i]

[b]PS. Code is free to use, it did not contain any copyrights or anything, and was available for free, just forgot where I got it from lol :)[/b]
Author:  Radar [ Sun Sep 15, 2013 3:51 am ]
Post subject:  Re: Need help with adding MaxSpread condition

Hey ThaiGuy,

Just add "extern double MaxSpread = 0.003" (without the quotes) for 30 pips, and change this...

Code: Select all

if (cA > 0) if (OrderSend(symb, OP_BUY, Lot(), ND(Ask), Slippage, 0, 0, Comm, Magic, 0, Blue) != -1) cA = 0;
if (cA < 0) if (OrderSend(symb, OP_SELL, Lot(), ND(Bid), Slippage, 0, 0, Comm, Magic, 0, Red) != -1) cA = 0;
to this...

Code: Select all

if (Ask - Bid <= MaxSpread)
{
if (cA > 0) if (OrderSend(symb, OP_BUY, Lot(), ND(Ask), Slippage, 0, 0, Comm, Magic, 0, Blue) != -1) cA = 0;
if (cA < 0) if (OrderSend(symb, OP_SELL, Lot(), ND(Bid), Slippage, 0, 0, Comm, Magic, 0, Red) != -1) cA = 0;
}
Have fun!

Radar =8^)
Author:  ThaiGuy [ Mon Sep 16, 2013 8:26 pm ]
Post subject:  Re: Need help with adding MaxSpread condition

thanks for your quick reply and sorry for my late response lol :)
All times are UTC Page 1 of 1