visual entry/exit plotted on indicator

#1
If you have an indicator, and buy/sell/short/cover and/or stoploss criteria, you can put the following code below.
This shows entry/exit value's with discription.

one important thing before use is to change is the base_array.
base_array = =????
replace the =???? with the value which is used to plot the indicator.

it's meant eod and use the opening of the next day als entry/exit.
(but this is depended on how the applystop is setup)

very nice, so here ya go.

// change the questionmarks the the value which is used to plot the indicator
base_array=??? ;

////////////////////////////// HIGHLY IMPORTANT ////////////////////

//ACTIVATE STOPS IN SETTINGS
e = Equity(1,0); /* Highly Important!!. "Removes all extra signals, evaluates
stops AND writes BACK signals to Sell/Cover arrays". As it should be!!*/

PlotShapes( Buy* shapeUpArrow , colorBlack, 0);
PlotShapes( Short* shapeDownArrow , colorBlack, 0);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - ruin stop
6 - n-bar stop
*/

PlotShapes(IIf(Cover==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Cover==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

PlotShapes(IIf(Sell==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Sell==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

////////////////////////////////////////////////////////////////////////////////
OffsetBuy = Param("Offset_Buy ", -9, -25, 25, 1 );
OffsetSell = Param("Offset_Sell ", 2, -25, 25, 1 );
OffsetShort = Param("Offset_Short ", 7, -25, 25, 1 );
OffsetCover = Param("Offset_Cover ", -3, -25, 25, 1 );

OND=Ref(O,1); //OPEN NEXT DAY
base_arrayBUY=base_array+OffsetBuy ; //just for offset
base_arraySELL=base_array+OffsetSell ; //just for offset
base_arraySHORT=base_array+OffsetShort ; //just for offset
base_arrayCOVER=base_array+OffsetCover ; //just for offset

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "EL " + OND[ i ], i, base_arrayBUY[ i ], colorGreen );
if( Sell AND NOT Short ) PlotText( "LE " + OND[ i ], i, base_arraySELL[ i ], colorBlue);
if( Short ) PlotText( "ES " + OND[ i ], i, base_arraySHORT[ i ], colorRed);
if( Cover AND NOT Buy ) PlotText( "SE " + OND[ i ], i, base_arrayCOVER[ i ], colorOrange);
}

////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
GraphXSpace=15;
uptrend=Buy;
downtrend=Short;
Plot( 2, "ribbon",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

//////////////////////////////////////////////////////////////////////////////
 
Last edited:
#3
Alright, here's a bit more code to have a try with.

you should have criteria with your indicator for long/sell/short/cover
if that's available, you put this code below.
It uses a profittarget en stoploss of 2.5% and here it uses also the opening of the next day to close.

Don't forget to change the questionmark !

explained:
EL = entry long (green)
LE = long exit (blue)

ES = entry short (red)
SE = short exit (orange)


copy code below here ..........................

// change the questionmarks the the value which is used to plot the indicator
base_array= ? ;


ExRem(Buy,Sell);
ExRem(Short,Cover);

PlotShapes( Buy * shapeUpTriangle, colorBrightGreen, 0);
PlotShapes( Short * shapeDownTriangle, colorOrange, 0);
PlotShapes( Sell * shapeSmallCircle, colorRed, 0,base_array,Offset=25);
PlotShapes( Cover * shapeSmallCircle, colorDarkGreen, 0,base_array,Offset=-25);

ApplyStop(stopTypeLoss, stopModePercent, Optimize( "stopTypeLoss", 2.5, 2.5, 2.5, 0.5 ) ,2, True );
ApplyStop(stopTypeProfit , stopModePercent, Optimize( "stopTypeProfit ", 2.5, 2.5, 2.5, 0.1 ) ,2, True );


////////////////////////////// HIGHLY IMPORTANT ////////////////////

//ACTIVATE STOPS IN SETTINGS
e = Equity(1,0); /* Highly Important!!. "Removes all extra signals, evaluates
stops AND writes BACK signals to Sell/Cover arrays". As it should be!!*/

PlotShapes( Buy* shapeUpArrow , colorBlack, 0);
PlotShapes( Short* shapeDownArrow , colorBlack, 0);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - ruin stop
6 - n-bar stop
*/

PlotShapes(IIf(Cover==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Cover==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

PlotShapes(IIf(Sell==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Sell==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

////////////////////////////////////////////////////////////////////////////////
OffsetBuy = Param("Offset_Buy (green)", -9, -25, 25, 1 );
OffsetSell = Param("Offset_Sell (blue)", 2, -25, 25, 1 );
OffsetShort = Param("Offset_Short (red)", 7, -25, 25, 1 );
OffsetCover = Param("Offset_Cover (orange)", -4, -25, 25, 1 );

OND=Ref(O,1); //OPEN NEXT DAY
base_arrayBUY=base_array+OffsetBuy ; //just for offset
base_arraySELL=base_array+OffsetSell ; //just for offset
base_arraySHORT=base_array+OffsetShort ; //just for offset
base_arrayCOVER=base_array+OffsetCover ; //just for offset

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "EL " + OND[ i ], i, base_arrayBUY[ i ], colorGreen );
if( Sell AND NOT Short ) PlotText( "LE " + OND[ i ], i, base_arraySELL[ i ], colorBlue);
if( Short ) PlotText( "ES " + OND[ i ], i, base_arraySHORT[ i ], colorRed);
if( Cover AND NOT Buy ) PlotText( "SE " + OND[ i ], i, base_arrayCOVER[ i ], colorOrange);
}

////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
GraphXSpace=15;
uptrend=Buy;
downtrend=Short;
Plot( 2, "ribbon",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

////////////////////////////////////////////////////////////////////////////////
 
Last edited:
#4
give me this error>>Error 29. Variable <name> used without having been initialized.
You can not use (read) the variable that was not initialized first. You should assign the value to the variable before reading it.

Example (incorrect usage):

x = 1;
z = x + y; // wrong, y is not initialized

Correct usage would look like this:


x = 1; // initialize x
y = 2; // initialize y
z = x + y; // correct, both x and y are initialized
 
#5
If you have an indicator, and buy/sell/short/cover and/or stoploss criteria, you can put the following code below.
This shows entry/exit value's with discription.

one important thing before use is to change is the base_array.
base_array = =????
replace the =???? with the value which is used to plot the indicator.

it's meant eod and use the opening of the next day als entry/exit.
(but this is depended on how the applystop is setup)

very nice, so here ya go.

// change the questionmarks the the value which is used to plot the indicator
base_array=??? ;



////////////////////////////// HIGHLY IMPORTANT ////////////////////

//ACTIVATE STOPS IN SETTINGS
e = Equity(1,0); /* Highly Important!!. "Removes all extra signals, evaluates
stops AND writes BACK signals to Sell/Cover arrays". As it should be!!*/

PlotShapes( Buy* shapeUpArrow , colorBlack, 0);
PlotShapes( Short* shapeDownArrow , colorBlack, 0);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - ruin stop
6 - n-bar stop
*/

PlotShapes(IIf(Cover==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Cover==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

PlotShapes(IIf(Sell==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Sell==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

////////////////////////////////////////////////////////////////////////////////
OffsetBuy = Param("Offset_Buy ", -9, -25, 25, 1 );
OffsetSell = Param("Offset_Sell ", 2, -25, 25, 1 );
OffsetShort = Param("Offset_Short ", 7, -25, 25, 1 );
OffsetCover = Param("Offset_Cover ", -3, -25, 25, 1 );

OND=Ref(O,1); //OPEN NEXT DAY
base_arrayBUY=base_array+OffsetBuy ; //just for offset
base_arraySELL=base_array+OffsetSell ; //just for offset
base_arraySHORT=base_array+OffsetShort ; //just for offset
base_arrayCOVER=base_array+OffsetCover ; //just for offset

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "EL " + OND[ i ], i, base_arrayBUY[ i ], colorGreen );
if( Sell AND NOT Short ) PlotText( "LE " + OND[ i ], i, base_arraySELL[ i ], colorBlue);
if( Short ) PlotText( "ES " + OND[ i ], i, base_arraySHORT[ i ], colorRed);
if( Cover AND NOT Buy ) PlotText( "SE " + OND[ i ], i, base_arrayCOVER[ i ], colorOrange);
}

////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
GraphXSpace=15;
uptrend=Buy;
downtrend=Short;
Plot( 2, "ribbon",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

//////////////////////////////////////////////////////////////////////////////






Dear friend
i have installed but giving error in amibroker
how to install! guide me to setup properly
my id here g_gupta12 @ y a h o o.com
 
#6
Dear friend
i have installed but giving error in amibroker
how to install! guide me to setup properly
my id here g_gupta12 @ y a h o o.com
Can you both guys read what birdseye has written?? YOU NEED A SYSTEM THAT GENERATES BUY SELL SHORT COVER SIGNALS!!
If you can't read then learn to read.
 
#7
true detwo, it's all about reading. Thanks for pointing that out !

im spending more time on this then I planned for, but what the heck.

Here is a complete example to show what it does. Including a basic system.

note that the ? is replaces with Ks
Because of that the arrows and dots are plotted on the blueline.

It's all about plotting the entry and exit values on the chart.

_SECTION_BEGIN("Stochastic %D%K");

//indicator criteria
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
KsDs = StochD( periods , Ksmooth, DSmooth );
Plot( KsDs , _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Ks = StochK( periods , Ksmooth);
Plot( Ks , _DEFAULT_NAME(), colorBlue, ParamStyle("Style") );

// criteria buy/short
up = Cross(Ks,KsDs);
down = Cross(KsDs,Ks);

Buy = Cover = up;
Short = Sell = down;
_SECTION_END();

// change the questionmarks the the value which is used to plot the indicator
base_array= ks ;


ExRem(Buy,Sell);
ExRem(Short,Cover);

PlotShapes( Buy * shapeUpTriangle, colorBrightGreen, 0);
PlotShapes( Short * shapeDownTriangle, colorOrange, 0);
PlotShapes( Sell * shapeSmallCircle, colorRed, 0,base_array,Offset=25);
PlotShapes( Cover * shapeSmallCircle, colorDarkGreen, 0,base_array,Offset=-25);

ApplyStop(stopTypeLoss, stopModePercent, Optimize( "stopTypeLoss", 2.5, 2.5, 2.5, 0.5 ) ,2, True );
ApplyStop(stopTypeProfit , stopModePercent, Optimize( "stopTypeProfit ", 2.5, 2.5, 2.5, 0.1 ) ,2, True );


////////////////////////////// HIGHLY IMPORTANT ////////////////////

//ACTIVATE STOPS IN SETTINGS
e = Equity(1,0); /* Highly Important!!. "Removes all extra signals, evaluates
stops AND writes BACK signals to Sell/Cover arrays". As it should be!!*/

PlotShapes( Buy* shapeUpArrow , colorBlack, 0);
PlotShapes( Short* shapeDownArrow , colorBlack, 0);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - ruin stop
6 - n-bar stop
*/

PlotShapes(IIf(Cover==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Cover==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

PlotShapes(IIf(Sell==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Sell==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

////////////////////////////////////////////////////////////////////////////////
OffsetBuy = Param("Offset_Buy (green)", -9, -25, 25, 1 );
OffsetSell = Param("Offset_Sell (blue)", 2, -25, 25, 1 );
OffsetShort = Param("Offset_Short (red)", 7, -25, 25, 1 );
OffsetCover = Param("Offset_Cover (orange)", -4, -25, 25, 1 );

OND=Ref(O,1); //OPEN NEXT DAY
base_arrayBUY=base_array+OffsetBuy ; //just for offset
base_arraySELL=base_array+OffsetSell ; //just for offset
base_arraySHORT=base_array+OffsetShort ; //just for offset
base_arrayCOVER=base_array+OffsetCover ; //just for offset

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "EL " + OND[ i ], i, base_arrayBUY[ i ], colorGreen );
if( Sell AND NOT Short ) PlotText( "LE " + OND[ i ], i, base_arraySELL[ i ], colorBlue);
if( Short ) PlotText( "ES " + OND[ i ], i, base_arraySHORT[ i ], colorRed);
if( Cover AND NOT Buy ) PlotText( "SE " + OND[ i ], i, base_arrayCOVER[ i ], colorOrange);
}

////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
GraphXSpace=15;
uptrend=Buy;
downtrend=Short;
Plot( 2, "ribbon",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

////////////////////////////////////////////////////////////////////////////////
 

shekharz

Active Member
#8
thanks for explaining

how can we do the same with AROON indicator, i couldn't find a way to do it, please tell us how to .......

shekharz
 
#9
here ya go

PL = Param("PL",14,4,45,1);
ALen = PL;

AroonUp = 100 * (ALen - (HHVBars(H, ALen + 1))) / Alen;
AroonDn = 100 * (ALen - (LLVBars(L, ALen + 1))) / ALen;

Plot(AroonUp, "Aroon Up", colorBrightGreen, styleThick);
Plot(AroonDn, "Aroon Dn", colorRed, styleThick);

Buy = Cover = Cross(AroonUp,AroonDn);
Short = Sell = Cross(AroonDn,AroonUp);

// change the questionmarks the the value which is used to plot the indicator
base_array= AroonUp;


ExRem(Buy,Sell);
ExRem(Short,Cover);

PlotShapes( Buy * shapeUpTriangle, colorBrightGreen, 0);
PlotShapes( Short * shapeDownTriangle, colorOrange, 0);
PlotShapes( Sell * shapeSmallCircle, colorRed, 0,base_array,Offset=25);
PlotShapes( Cover * shapeSmallCircle, colorDarkGreen, 0,base_array,Offset=-25);

ApplyStop(stopTypeLoss, stopModePercent, Optimize( "stopTypeLoss", 2.5, 2.5, 2.5, 0.5 ) ,2, True );
ApplyStop(stopTypeProfit , stopModePercent, Optimize( "stopTypeProfit ", 2.5, 2.5, 2.5, 0.1 ) ,2, True );


////////////////////////////// HIGHLY IMPORTANT ////////////////////

//ACTIVATE STOPS IN SETTINGS
e = Equity(1,0); /* Highly Important!!. "Removes all extra signals, evaluates
stops AND writes BACK signals to Sell/Cover arrays". As it should be!!*/

PlotShapes( Buy* shapeUpArrow , colorBlack, 0);
PlotShapes( Short* shapeDownArrow , colorBlack, 0);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - ruin stop
6 - n-bar stop
*/

PlotShapes(IIf(Cover==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Cover==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

PlotShapes(IIf(Sell==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Sell==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

////////////////////////////////////////////////////////////////////////////////
OffsetBuy = Param("Offset_Buy (green)", -9, -25, 25, 1 );
OffsetSell = Param("Offset_Sell (blue)", 2, -25, 25, 1 );
OffsetShort = Param("Offset_Short (red)", 7, -25, 25, 1 );
OffsetCover = Param("Offset_Cover (orange)", -4, -25, 25, 1 );

OND=Ref(O,1); //OPEN NEXT DAY
base_arrayBUY=base_array+OffsetBuy ; //just for offset
base_arraySELL=base_array+OffsetSell ; //just for offset
base_arraySHORT=base_array+OffsetShort ; //just for offset
base_arrayCOVER=base_array+OffsetCover ; //just for offset

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "EL " + OND[ i ], i, base_arrayBUY[ i ], colorGreen );
if( Sell AND NOT Short ) PlotText( "LE " + OND[ i ], i, base_arraySELL[ i ], colorBlue);
if( Short ) PlotText( "ES " + OND[ i ], i, base_arraySHORT[ i ], colorRed);
if( Cover AND NOT Buy ) PlotText( "SE " + OND[ i ], i, base_arrayCOVER[ i ], colorOrange);
}

////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
GraphXSpace=15;
uptrend=Buy;
downtrend=Short;
Plot( 2, "ribbon",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

////////////////////////////////////////////////////////////////////////////////
 
#10
here's another example zigzag
needs to be dragged over a price chart

_SECTION_BEGIN("Zig-zag Indicator");

P = ParamField( "Price field" );
change = Param("% change",1,0.1,25,0.1);
z= Zig(P, change);
Plot( z, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );

Buy=Cover= z > Ref(z,-1);
Short=Sell= z < Ref(z,-1);

_SECTION_END();

_SECTION_BEGIN("plot levels");
// change the questionmarks the the value which is used to plot the indicator
base_array=z;

////////////////////////////// HIGHLY IMPORTANT ////////////////////

//ACTIVATE STOPS IN SETTINGS
e = Equity(1,0); /* Highly Important!!. "Removes all extra signals, evaluates
stops AND writes BACK signals to Sell/Cover arrays". As it should be!!*/

PlotShapes( Buy* shapeUpArrow , colorBlack, 0);
PlotShapes( Short* shapeDownArrow , colorBlack, 0);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - ruin stop
6 - n-bar stop
*/

PlotShapes(IIf(Cover==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Cover==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

PlotShapes(IIf(Sell==2, shapeCircle, shapeNone),colorRed,0,base_array,0); //stoploss
PlotShapes(IIf(Sell==3, shapeCircle, shapeNone),colorGreen,0,base_array,0); //profit target

////////////////////////////////////////////////////////////////////////////////
OffsetBuy = Param("Offset_Buy (green)", -9, -25, 25, 1 );
OffsetSell = Param("Offset_Sell (blue)", 2, -25, 25, 1 );
OffsetShort = Param("Offset_Short (red)", 7, -25, 25, 1 );
OffsetCover = Param("Offset_Cover (orange)", -4, -25, 25, 1 );

OND=Ref(O,1); //OPEN NEXT DAY
base_arrayBUY=base_array+OffsetBuy ; //just for offset
base_arraySELL=base_array+OffsetSell ; //just for offset
base_arraySHORT=base_array+OffsetShort ; //just for offset
base_arrayCOVER=base_array+OffsetCover ; //just for offset

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "EL " + OND[ i ], i, base_arrayBUY[ i ], colorGreen );
if( Sell AND NOT Short ) PlotText( "LE " + OND[ i ], i, base_arraySELL[ i ], colorBlue);
if( Short ) PlotText( "ES " + OND[ i ], i, base_arraySHORT[ i ], colorRed);
if( Cover AND NOT Buy ) PlotText( "SE " + OND[ i ], i, base_arrayCOVER[ i ], colorOrange);
}

_SECTION_END();
////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
GraphXSpace=15;
uptrend=Buy;
downtrend=Short;
Plot( 2, "ribbon",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

//////////////////////////////////////////////////////////////////////////////
 

Similar threads