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

Wapens Renko hedges
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2748
Page 1 of 1
Author:  traderduke [ Mon Jul 22, 2013 5:28 pm ]
Post subject:  Wapens Renko hedges

Can anybody stop/fix this EA from hedging in the opposite position. By fix I mean don't try to BUY when you have a Short position. This EA was meant to add to its BUY position at times but not hedge in the opposite direction.

Not sure of terminology, does hedge mean enter opposite position or can it mean add to present position ??

thanks

Ray
Author:  phil_trade [ Mon Jul 22, 2013 8:08 pm ]
Post subject:  Re: Wapens Renko hedges

traderduke wrote:Can anybody stop/fix this EA from hedging in the opposite position. By fix I mean don't try to BUY when you have a Short position. This EA was meant to add to its BUY position at times but not hedge in the opposite direction.

Not sure of terminology, does hedge mean enter opposite position or can it mean add to present position ??

thanks

Ray
Hi

you can use/adapt code from Marylin http://www.stevehopwoodforex.com/phpBB3 ... f=5&t=1448

ex. for sell

Code: Select all

if(CountBuys(Symbol(),MagicNumber)==0)
{
/... your sell code
}

Code: Select all

if(CountSells(Symbol(),MagicNumber)==0)
{
/... your buy code
}

Code: Select all

int CountBuys(string strSymbol, int nMagic)
{
	int nOrderCount=0;
	for (int i=OrdersTotal()-1 ; i>=0 ; i--)
	{
		if (!OrderSelect(i,SELECT_BY_POS)) continue;
		if (OrderType() == OP_BUY)
		if (OrderMagicNumber() == nMagic)
		if (OrderSymbol() == strSymbol)
		nOrderCount++;
	}
	return(nOrderCount);
}



int CountSells(string strSymbol, int nMagic)
{
	int nOrderCount=0;
	for (int i=OrdersTotal()-1 ; i>=0 ; i--)
	{
		if (!OrderSelect(i,SELECT_BY_POS)) continue;
		if (OrderType() == OP_SELL)
		if (OrderMagicNumber() == nMagic)
		if (OrderSymbol() == strSymbol)
		nOrderCount++;
	}
	return(nOrderCount);
}
Cheers

Philippe
Author:  traderduke [ Wed Jul 24, 2013 7:41 pm ]
Post subject:  Re: Wapens Renko hedges

Phil
Thanks for info, I'll give it a try.

Ray
phil_trade wrote:
traderduke wrote:Can anybody stop/fix this EA from hedging in the opposite position. By fix I mean don't try to BUY when you have a Short position. This EA was meant to add to its BUY position at times but not hedge in the opposite direction.

Not sure of terminology, does hedge mean enter opposite position or can it mean add to present position ??

thanks

Ray
Hi

you can use/adapt code from Marylin http://www.stevehopwoodforex.com/phpBB3 ... f=5&t=1448

ex. for sell

Code: Select all

if(CountBuys(Symbol(),MagicNumber)==0)
{
/... your sell code
}

Code: Select all

if(CountSells(Symbol(),MagicNumber)==0)
{
/... your buy code
}

Code: Select all

int CountBuys(string strSymbol, int nMagic)
{
	int nOrderCount=0;
	for (int i=OrdersTotal()-1 ; i>=0 ; i--)
	{
		if (!OrderSelect(i,SELECT_BY_POS)) continue;
		if (OrderType() == OP_BUY)
		if (OrderMagicNumber() == nMagic)
		if (OrderSymbol() == strSymbol)
		nOrderCount++;
	}
	return(nOrderCount);
}



int CountSells(string strSymbol, int nMagic)
{
	int nOrderCount=0;
	for (int i=OrdersTotal()-1 ; i>=0 ; i--)
	{
		if (!OrderSelect(i,SELECT_BY_POS)) continue;
		if (OrderType() == OP_SELL)
		if (OrderMagicNumber() == nMagic)
		if (OrderSymbol() == strSymbol)
		nOrderCount++;
	}
	return(nOrderCount);
}
Cheers

Philippe
All times are UTC Page 1 of 1