This can be useful for limiting your Martingale orders to lastOrderPrice +/- something... like 50 pips for example, in your trading conditions. Obviously, this is for SB Pro users.
First, declare 3 new variables in your global variables like so:
Code:
double lastOrderPrice;
double mPipBuffer;
extern int MartingalePips=50;
Note that extern creates a new adjustable EA input!
Then, put the following code under:
int start
()Code:
for (int i=OrdersTotal()-1; i>=0; i--)
{
if ( OrderSelect(i,SELECT_BY_POS, MODE_TRADES) )
{
if ( OrderType() == ( OP_SELL || OP_BUY )
&& OrderSymbol() == Symbol()
&& OrderMagicNumber() == ( MagicNumberShort || MagicNumberLong ) )
lastOrderPrice = OrderOpenPrice();
}
}
mPipBuffer = MartingalePips * PipMultiplier * Point;
Of course, the last step is adding
&& iClose(Symbol(),0,0)>=lastOrderPrice+mPipBuffer to your BUY condition for example. I trust the admins will tell me if I have it wrong. Hopefully this will inspire others to post their hardcode mod's as well.