Simple Coding Help - No Promise.

Found and modified this one,try this now.
Code:
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
GraphXSpace = 5;
Plot(C,"",colorBlack,styleCandle);
x = Ref(H,-1);
Y = Ref(L,-1);
a=x+1;
b=y-1;
aa=EMA(C,20);
bb=EMA(C,50);
Buy = Cover = C>a AND aa>bb;
Sell = Short = C<b AND aa<bb;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,L,-15);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
thank u so much for help. problem solved..

Buy1 = Cross(EMA1,EMA2);
Sell1 = Cross(EMA2,EMA1);

Buy2=ValueWhen(Buy1,H);
sell2=ValueWhen(Sell1,L);

Buy=Cross(C,Buy2);
Sell=Cross(Sell2,C);
 

Nehal_s143

Well-Known Member
My understanding is that you want to buy above bar that closes above upper pink, short below lower pink.....cover high above lower pink and sell low below upper pink. Correct?

Because if that is the case I don't think 2 sets of buy short etc are required
Sir logic used here is want to buy/sell on retrenchment, in above case will sell if price touch to red line for perfect retrenchment but many time price comes near red line and start falling without touching the red line and we miss the chance
hence bottom pink line is used as filter, so that if price comes above or touches or cross bottom pink line and fails to touch red line and closed below pink line, we should be able to take sell with out waiting price to touch red line

re. exit, in above case we will exit short if price touch/cross red line or filter value of red line i.e 0.01% or 0.02% from red line
 
Hi

I am got stuck in below two conditions badly, I tried . . .
check if this is what you are aiming for . . .


Code:
// touch 
touchExitShort = H > NWf2f;
touchExitLong  = L < NWf2f;

Buy1 = Cover1 = jf2f > NWf2f;
//Sell1 = touchExitLong;
Short1 = Sell1 = jf2f<NWf2f;
//Cover1 = touchExitShort;

Buy1=ExRem(Buy1,Sell1);
Short1=ExRem(Short1,Cover1);
Sell1=ExRem(Sell1,Buy1);
Cover1=ExRem(Cover1,Short1);

LONG = Flip(Buy1,Short1);

PlotShapes(Buy1* shapeUpArrow,colorBlue, 0,L, Offset=-45); 
PlotShapes(Short1* shapeDownArrow,colorRed, 0,H, Offset=-45);
PlotShapes(Sell1*shapeHollowDownArrow,colorPink,0,L,-56);
PlotShapes(Cover1*shapeHollowUpArrow,colorSkyblue,0,H,-56);


Buy2 = LONG AND NOT(Buy1) AND C > NWB;
Sell2 = touchExitLong;
Short2 = NOT(LONG) AND NOT Short1 AND C < NWT;
Cover2 = touchExitShort;

Buy2=ExRem(Buy2,Sell2);
Short2=ExRem(Short2,Cover2);
Sell2=ExRem(Sell2,Buy2);
Cover2=ExRem(Cover2,Short2);

PlotShapes(Buy2* shapeUpArrow,colorGreen, 0,L, Offset=-51); 
PlotShapes(Short2* shapeDownArrow,colorOrange, 0,H, Offset=-51);
PlotShapes(Sell2*shapeHollowDownArrow,colorPink,0,L,-61);
PlotShapes(Cover2*shapeHollowUpArrow,colorSkyblue,0,H,-61);

replace this last part of the code . . .



Happy :)
 

pratapvb

Well-Known Member
Sir logic used here is want to buy/sell on retrenchment, in above case will sell if price touch to red line for perfect retrenchment but many time price comes near red line and start falling without touching the red line and we miss the chance
hence bottom pink line is used as filter, so that if price comes above or touches or cross bottom pink line and fails to touch red line and closed below pink line, we should be able to take sell with out waiting price to touch red line

re. exit, in above case we will exit short if price touch/cross red line or filter value of red line i.e 0.01% or 0.02% from red line
Not getting it
 

xsis

Active Member
dear coders - a small request!

can the following amibroker default afl of relative performance be extended to 5-10 more ticker comparison?

i.e. in param window, there should b an option of 5-10 ticker comparison with the base symbol!

Code:
_SECTION_BEGIN("Relative Performance");
_N( TickerList = ParamStr("Tickers", "^DJI,MSFT,GE") );
NumBars = 20;
fvb = Status("firstvisiblebar");
Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name(), colorBlue );
for( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
 fc = Foreign( symbol, "C" );

 if( ! IsNull( fc[ 0 ] ) )
 {
   Plot( 100 * ( fc - fc[ fvb ] )/ fc[ fvb ], symbol, colorLightOrange + ( (2*i) % 15 ), styleLine );
 }
}
PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );
_SECTION_END();
 

trash

Well-Known Member
dear coders - a small request!

can the following amibroker default afl of relative performance be extended to 5-10 more ticker comparison?

i.e. in param window, there should b an option of 5-10 ticker comparison with the base symbol!

Code:
_SECTION_BEGIN("Relative Performance");
_N( TickerList = ParamStr("Tickers", "^DJI,MSFT,GE") );
NumBars = 20;
fvb = Status("firstvisiblebar");
Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name(), colorBlue );
for( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
 fc = Foreign( symbol, "C" );

 if( ! IsNull( fc[ 0 ] ) )
 {
   Plot( 100 * ( fc - fc[ fvb ] )/ fc[ fvb ], symbol, colorLightOrange + ( (2*i) % 15 ), styleLine );
 }
}
PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );
_SECTION_END();
Then why don't you just add more symbols yourself? Just type. Three ones are there as example. You can remove them in parameter dialog and add your ones there or in the code you add your preferred ones in place of the existing ones. What is the difficulty?

Alternatively you can loop through filled categories. So move your symbol to watchlist(s) and then choose the name of each watchlist in parameter dialog if applying below code. Or is that too much difficult also (if just typing is already too difficult)?

Seriously sometimes one can only shake one's head witnessing mankind's helplessness.

Code:
_SECTION_BEGIN("Relative Performance");
// adjusted by trash, 2014

cat = categoryWatchlist;// choose category, the more symbols are in that category the slower the execution so take care if there are thousands of symbols
WLStr = "";

// search for filled watchlists and make a string of all of them
for ( w = 0; w < 256; w++ )
{
    WList = CategoryGetName( cat, w );
    WLmembers = CategoryGetSymbols( cat, w );

    if ( WLmembers != "" )
        WLStr += WList + ",";
}
CatList = ParamList ( "Choose filled List", WLStr );
wlnum   = CategoryFind( CatList, cat );// uses name to get category WL number 
            
//_N( TickerList = ParamStr("Tickers", "^DJI,MSFT,GE,AAPL,INTC,DELL,CSCO") );
_N( TickerList = CategoryGetSymbols( Cat, wlnum ) );

fvb = Status("firstvisiblebar");
Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name(), colorBlue );

for ( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
    fc = Foreign( symbol, "C" );

    if ( ! IsNull( fc[ 0 ] ) )
    {
        Plot( 100 * ( fc - fc[ fvb ] ) / fc[ fvb ], symbol, colorLightOrange + ( ( 2*i ) % 15 ), styleLine );
    }
}
PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - List: " + catList + " - Relative Performance [%]: {{VALUES}}" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartWrapTitle );
_SECTION_END();
 
Last edited:
Guys, can anyone tell me what I'm doing wrong in my BreakEven code?



Buy = Condition...;
Short = Condition...;

Sell = TimeNum() > 171500;
Cover = TimeNum() > 171500;

//Now the BreakEven functionallity. It has a:

//Initial Loss;
//Initial Gain;
//Loss moves to breakeven if prices moves 90 points (future mode);

PriceAtBuy = 0;
PriceAtShort = 0;
Highest_Since_Buy = 0;
Lowest_Since_Short = 0;
Buy_Stage = 0;
Short_Stage = 0;

//Buy:

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

{
if (PriceAtBuy == 0 AND Buy)
{
PriceAtBuy = BuyPrice;
}

if (PriceAtBuy > 0)
{
Highest_Since_Buy = Max(High, Highest_Since_Buy);
}

if (Buy_Stage == 0 AND PriceAtBuy > 0 AND Low <= PriceAtBuy - 100)
{
Sell = 1;
SellPrice = PriceAtBuy - 100;
PriceAtBuy = 0;
Highest_Since_Buy = 0;
Buy = 0;
}


if (Buy_Stage == 0 AND PriceAtBuy > 0 AND Highest_Since_Buy >= PriceAtBuy + 90)
{
Buy_Stage = 1;
}

if (Buy_Stage == 1 AND PriceAtBuy > 0 AND Low <= PriceAtBuy)
{
Sell = 1;
SellPrice = PriceAtBuy + 10;
PriceAtBuy = 0;
Highest_Since_BuyC = 0;
Buy_Stage = 0;
Buy = 0;
}

if (Buy_Stage == 1 AND PriceAtBuy > 0 AND High >= PriceAtBuy + 200 )
{
Sell = 1;
SellPrice = PriceAtBuy + 200;
PriceAtBuy = 0;
Highest_Since_Buy = 0;
Buy_Stage = 0;
Buy = 0;
}






}



//Short:

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

{
if (PriceAtShort == 0 AND Short)
{
PriceAtShort = ShortPrice;
}

if (PriceAtShort > 0)
{
Lowest_Since_Short = Min(Low, Lowest_Since_Short);
}

if (Short_Stage == 0 AND PriceAtShort > 0 AND High >= PriceAtShort + 100)
{
Cover = 1;
CoverPrice = PriceAtShort + 100;
PriceAtShort = 0;
Lowest_Since_Short = 0;
Short = 0;
}


if (Short_Stage == 0 AND PriceAtShort > 0 AND Lowest_Since_Short <= PriceAtShort - 90)
{
Short_Stage = 1;
}

if (Short_Stage == 1 AND PriceAtShort > 0 AND High >= PriceAtShort)
{
Cover = 1;
CoverPrice = PriceAtShort - 10;
PriceAtShort = 0;
Lowest_Since_Short = 0;
Short_Stage = 0;
Short = 0;
}

if (Short_Stage == 1 AND PriceAtShort > 0 AND Low <= PriceAtShort - 200 )
{
Cover = 1;
CoverPrice = PriceAtShort - 200;
PriceAtShort = 0;
Lowest_Since_Short = 0;
Short_Stage = 0;
Short = 0;
}






}
 

xsis

Active Member
@trash - u have every right to get angry with me for my stupidity. at the same time i am extremely sorry to u & forum for wasting some precious time of yours!

since i am new to amibroker, in haste i just added space between tickers & comma and couldnt get the charts! my mistake :mad:

but cud u help me in another request. this time i have doubled checked myself :) pls have a look at the next post!

Then why don't you just add more symbols yourself? Just type. Three ones are there as example. You can remove them in parameter dialog and add your ones there or in the code you add your preferred ones in place of the existing ones. What is the difficulty?

Alternatively you can loop through filled categories. So move your symbol to watchlist(s) and then choose the name of each watchlist in parameter dialog if applying below code. Or is that too much difficult also (if just typing is already too difficult)?

Seriously sometimes one can only shake one's head witnessing mankind's helplessness.
 

xsis

Active Member
dear coders - a small request!

in the below code for correlation can we add exploration which gives correlation values against the base ticker by exploring a watchlist?

Code:
_SECTION_BEGIN("Historical Correlaion");
symbol = ParamStr("Correlation ticker", GetBaseIndex() );
fc = Foreign( symbol, "C" );
Plot( Correlation(C,fc,60), _SECTION_NAME() + "(" + symbol + ")", ParamColor( "color", colorCycle ), ParamStyle("Style")  );
_SECTION_END();
 

trash

Well-Known Member
@trash - u have every right to get angry with me for my stupidity. at the same time i am extremely sorry to u & forum for wasting some precious time of yours!

since i am new to amibroker, in haste i just added space between tickers & comma and couldnt get the charts! my mistake :mad:
I'm not angry at all but am just astonished that a simple line like this one
_N( TickerList = ParamStr("Tickers", "^DJI,MSFT,GE") );

being at the top didn't make sense to you.

Isn't it logical consequence that if you see three symbols there that you can change them to anything else as your preferred default symbols or any number of additional symbols? There is even a help document explaining that function and any other one.

Again you can input any symbols in that code line to define your default values or you can leave it blank like this

_N( TickerList = ParamStr("Tickers", "") );

and then you input your symbols in parameter dialog

Or you keep those symbols and delete them in the parameter dialog to input your own values afterwards. It is pretty simple.

People, just play around with codes in general. You won't ignite any nuclear bomb. It doesn't hurt playing around with codes. It won't kill you all. Don't be shy.
 

Similar threads