Hi,
I am using renko charts and what I am trying to do is on the close of every brick that is in the opposite direction of the previous brick open a trade in the driection of the current completed brick.
Now I thought this would be easy but the 2 things I am having a problem with is
1). Cant get the Arrows to show up on the correct brick.
2). When runing the back test if there is only 1 brick at the far right in a different direction a trade is not opened.
Any Ideas?
Thanks for your Time and Effort
EK
I am using renko charts and what I am trying to do is on the close of every brick that is in the opposite direction of the previous brick open a trade in the driection of the current completed brick.
Now I thought this would be easy but the 2 things I am having a problem with is
1). Cant get the Arrows to show up on the correct brick.
2). When runing the back test if there is only 1 brick at the far right in a different direction a trade is not opened.
PHP Code:
//External Variables
var nBarCounter = 0;
var nFac = null;
var nVal2 = null;
var aFPArray = new Array();
var bInitialized = false;
var OldPlot = 0;
var nStatus = 0;
var nAdj = 0;
var grID = 0;
var nFontSize = 10;
var EntryPrice = 0;
var AlertYes = -1;
//== PreMain function required by eSignal to set things up
function preMain() {
var x;
setPriceStudy(true);
setStudyTitle("EK New");
setShowTitleParameters( false );
setComputeOnClose(true);
//initialize formula parameters
aFPArray[x] = new FunctionParameter( "DoAlert", FunctionParameter.STRING);
with( aFPArray[x] ) {
addOption("Yes");
addOption("No");
setDefault("Yes");
}
}
//== Main processing function
function main( DoAlert ) {
//script is initializing
if ( getBarState() == BARSTATE_ALLBARS ) {
return null;
}
if ( bInitialized == false ) {
if ( DoAlert == "Yes" )
AlertYes = 1;
else
AlertYes = -1;
bInitialized = true;
}
//called on each new bar
if ( getBarState() == BARSTATE_NEWBAR ) {
if (nStatus == -1 || nStatus == 0 )
{
if (close() > close(-1) )
{
EntryPrice = close()
goLong();
}
}
if (nStatus == 1 || nStatus == 0 )
{
if (close(-1) > close() )
{
EntryPrice = close();
goShort();
}
}
}
}
//== gID function assigns unique identifier to graphic/text routines
function gID() {
grID ++;
return( grID );
}
//== draw the buy/sell arrows and text
function drawBuySell( sText, nDir, nColor, nPrice ) {
var nOffset;
nOffset = getCurrentBarIndex()==0 ? 0 : 1;
//buy or cover
if ( nDir==1 ) {
drawShapeRelative(-2, low(nOffset)-nAdj, Shape.UPARROW, "", Color.magenta, Shape.TOP | Shape.ONTOP , gID());
drawTextRelative(-2, low(nOffset)-(nAdj*1.5), sText, nColor, null, Text.CENTER | Text.TOP | Text.BOLD | Text.ONTOP, null, nFontSize, gID());
return( true );
}
//short or sell
if ( nDir==-1 ) {
drawShapeRelative(-2, high(nOffset)+nAdj, Shape.DOWNARROW, "", Color.maroon, Shape.BOTTOM | Shape.ONTOP , gID());
drawTextRelative(-2, high(nOffset)+(nAdj*1.5), sText, nColor, null, Text.BOTTOM | Text.CENTER | Text.BOLD | Text.ONTOP, null, nFontSize, gID());
return( true );
}
}
//== initiate a long trade
function goLong() {
nStatus = 1;
Strategy.doLong("Long", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT );
//drawBuySell( "Long", 1, Color.green, open(1) );
if ( AlertYes ){
Alert.email("Go Long", "EK Alert");
Alert.addToList( getSymbol(), "Go Long", Color.RGB(0,0,0), Color.RGB(0,0,255) );
Alert.playSound( "v:\\vault\\Hey Boy Sound.wav" );
}
}
//== initiate a short trade
function goShort() {
nStatus = -1;
Strategy.doShort("Short", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT );
//drawBuySell( "Shrt", -1, Color.red, open(1) );
if ( AlertYes )
{
Alert.email("Go Short", "EK Alert");
Alert.addToList( getSymbol(), "Go Short", Color.RGB(0,0,0), Color.RGB(255,0,0) );
Alert.playSound( "v:\\vault\\Hey Boy Sound.wav" );
}
}
Thanks for your Time and Effort
EK
Comment