How to implement a Stop ATR on Renko in a temporal Chart


#1

Hi.

I want to implement a Stop ATR on Renko (like 2R) in a temporal Chart (like M1). Can anyone help me?

Thanks,
Claudio


#2

You need to get Renko code from AFL library for example this http://www.amibroker.com/members/library/detail.php?id=521 as a starting point plus KB article http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/


#3

Thanks, Tomasz…

I already know these links. My EA uses the code provided there. The first link as far as I can see, helps us to build up a Renko Chart and plot it. The second one helps us to plot a trailing stop in a regular price chart. This worked fine for me.

However, I wanted to do the other way round… I wanted to use a regular Chart, with a Renko Stop ATR. I don’t even need to plot the Renko Chart, only the Renko Stop ATR. I want my EA to operate in a regular Chart but to exit trades through a Renko Stop ATR.

I tried to adapt 2 FOR loops that appeared on the second link of your post in the following manner:

// Calculates Renko Stop ATR trailARRAY = Null; trailstop = 0;

for( i = 0; i < BarCount; i++)
{
if( trailstop == 0 AND Buy[ i ] )
{
trailstop = RKH[ i ] - StopLength [ i ] ;
}
else
{
Buy[ i ] = 0; // remove excess buy signals
}

if( trailstop > 0 AND RKL[ i ] < trailstop )
{
	Sell[ i ] = 1;
	SellPrice[ i ] = trailstop;
	trailstop = 0;
}
	
if(trailstop > 0)
{
	trailstop = Max( RKH[ i ] - StopLength [ i ], trailstop );
	trailARRAY[ i ] = trailstop;
}

}

for ( i = 0; i < BarCount ; i++)
{

if( trailstop == 0 AND Short[ i ] )
{
	trailstop = RKL[ i ] + StopLength [ i ] ;
}
else
{
	Short[ i ] = 0; // remove excess short signals
}
	
if( trailstop > 0 AND RKH[ i ] > trailstop )
{
	Cover[ i ] = 1;
	CoverPrice[ i ] = trailstop;
	trailstop = 0;
}

//position = False;
	
if(trailstop > 0)
{
	trailstop = Min( RKL[ i ] + StopLength [ i ], trailstop );
	trailARRAY[ i ] = trailstop;
}

}

I replaced High for RKH and Low for RKL. I wanted to build the Renko bars just to calculate the stop. The result was strange… If I plot the stop with a Brick value of 1, the stop appears very far from the bars… In practice, the stop is never reached. Does my code makes sense? Am I missing something? Can I use a FOR from 1 to BarCount in a Renko Chart? How can I relate a Renko stop ATR with a regular temporal Chart?

Thanks,
Claudio


#4

Hi! Anyone has any comments?