Simple Coding Help - No Promise.

_SECTION_BEGIN("Bollinger Bands");

_SECTION_BEGIN("DispMA");
P = ParamField("Field");
Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
Periods = Param("Periods", 8, 2, 300 );
Displacement = Param("Displacement", 3, -50, 50 );
m = 0;

if( Type == "Simple" ) m = MA( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Weighted" ) m = WMA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorCycle), ParamStyle("Style"), 0, 0, Displacement );
_SECTION_END();



P=m ;
//P = ParamField("Price field",-1);
Periods = Param("Periods", 8, 2, 300, 1 );
Width = Param("Width", 1, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();

MA8 = MA(C,8);
//Plot(MA8,"MA8",colorRed,styleThick);
_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

dear all
can any one add buy signal above top bollinger band
and sell below at bottom bollinger band
with arrow pls
 
_SECTION_BEGIN("Bollinger Bands");

_SECTION_BEGIN("DispMA");
P = ParamField("Field");
Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
Periods = Param("Periods", 8, 2, 300 );
Displacement = Param("Displacement", 3, -50, 50 );
m = 0;

if( Type == "Simple" ) m = MA( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Weighted" ) m = WMA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorCycle), ParamStyle("Style"), 0, 0, Displacement );
_SECTION_END();



P=m ;
//P = ParamField("Price field",-1);
Periods = Param("Periods", 8, 2, 300, 1 );
Width = Param("Width", 1, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();

MA8 = MA(C,8);
//Plot(MA8,"MA8",colorRed,styleThick);
_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

dear all
can any one add buy signal above top bollinger band
and sell below at bottom bollinger band
with arrow pls
Try something like this:

Buy = C < ( BBandBot( P, Periods, Width );
Sell = C > ( BBandBot( P, Periods, Width );

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, L, H ), -25 );
 
Hi Senior Mmber and Happy Sir

Can you please let me know how to plot the below trailing stop loss in Amibroker

Trailng stop : Highest low(taking highest low of every bar) - atr(20)
 

trash

Well-Known Member
That's what I try to found somewhere, the "loop" method to rewrite the function itself! Just something I noted:

The algorithm itself plots "same pattern" as the built in NVI() formula at Ami, but given some time; the Ami indicator index growth much more than the one your wrote with the same array CLOSE.

Eventhough this little issue, the function plots what it supposed to plot given this mathematical criteria!

Thanks a lot Trash! :clap:

Because you have given the wrong equation. It is not summation but multiplication!


Code:
_SECTION_BEGIN( "Modded Negative Volume Index" );
// fixed self referencing  by trash
function xNVI(array)
{
    xROC = ROC( array, 1 ) / 100 + 1;
    Vcond = ROC( V, 1 ) < 0;

    _NVI = 100; // initialize _NVI

    for ( i = 1; i < BarCount; i++ )
    {
        prevNVI = _NVI[ i - 1 ]; // previous value of _NVI

        if ( Vcond[i] )
            _NVI[ i ] = prevNVI * xROC[ i ];
        else
            _NVI[ i ] = prevNVI;
    }

    return _NVI;
}

Plot( xNVI( Close ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle( "Style" ) );
Plot( NVI(), _DEFAULT_NAME() + " built-in", ColorRed, ParamStyle( "Style" ) );
_SECTION_END();
 

ocil

Well-Known Member
Hi Friends can any one help me on below code i want to plot day high and day low/week high week low/month high/low spread on chart. Thanks for your help.
_SECTION_BEGIN("Future Spread");
SetChartOptions(0,chartShowArrows|chartShowDates);

_N( Symbol1= ParamStr("Strike1", "CROMPGREAV-I") );

SetForeign( Symbol1 );
C1 = C;
H1 = H;
L1 = L;
O1 = O;
V1 = V;
RestorePriceArrays();


_N( Symbol2= ParamStr("Strike2", "VOLTAS-I") );

SetForeign( Symbol2 );
C2 = C;
H2 = H;
L2 = L;
O2 = O;
V2 = V;
RestorePriceArrays();

Color = ParamColor( "Color", colorRed );
Style = ParamStyle( "Style", styleSwingDots | styleThick );


PlotOHLC( abs(O1-O2), abs(H1-H2), abs(L1-L2), abs(C1-C2), "(" + Symbol1+" - "+Symbol2 + ") spread", Color, style );

_SECTION_END();
 
Hi Guys!!.. Pretty simple code (i'm just trying to get a feel of Amibroker syntax). Using standard RSI numbers.

I basically want to Sell at the open 5 days after a getting a Buy signal (buying at the close). I also only want to execute the next Buy after the Sell has been completed.

I'm using the following code below but looking at the trades list and the actual trade buy/sell arrows on the chart, there are multiple occasions where there are buy/sell transactions on the same day and Sell/Buy arrows on consecutive days.

Is my syntax for the sell delays and removal of excess signals wrong?

Appreciate the help guys. Thanks.


SetOption( "MaxOpenPositions", 50);
SetPositionSize( 2, spsPercentofequity );


RSILength = 14;

RSIBuyLevel = 30;

RSI4 = RSIa( C, RSILength ) ;


Buy = RSI4 < RSIBuyLevel;
SellPrice = Open; // Sell at open price

Sell = Ref (Buy, -5); //Sell 5 days after purchase
Buy = ExRem(buy, sell); //No buy signal till Sell is done
 

trash

Well-Known Member
Hi Guys!!.. Pretty simple code (i'm just trying to get a feel of Amibroker syntax). Using standard RSI numbers.

I basically want to Sell at the open 5 days after a getting a Buy signal (buying at the close). I also only want to execute the next Buy after the Sell has been completed.

I'm using the following code below but looking at the trades list and the actual trade buy/sell arrows on the chart, there are multiple occasions where there are buy/sell transactions on the same day and Sell/Buy arrows on consecutive days.

Is my syntax for the sell delays and removal of excess signals wrong?

Appreciate the help guys. Thanks.


SetOption( "MaxOpenPositions", 50);
SetPositionSize( 2, spsPercentofequity );


RSILength = 14;

RSIBuyLevel = 30;

RSI4 = RSIa( C, RSILength ) ;


Buy = RSI4 < RSIBuyLevel;
SellPrice = Open; // Sell at open price

Sell = Ref (Buy, -5); //Sell 5 days after purchase
Buy = ExRem(buy, sell); //No buy signal till Sell is done
Your sell rule is wrong. Never ever use similar rules as nbar exit because of further buy signals being true after initial buy entry. Use applystop function with nbar stop mode and set sell to zero.

In addition exrem is not required in analysis window.
 
Thanks for that trash. I'm not too familiar with the applystop function parameters and syntax. I tried the following but could not achieve the desired effect. Could you help me out please. Thanks

SetOption( "MaxOpenPositions", 50);
SetPositionSize( 2, spsPercentofequity );

RSILength = 14;

RSIBuyLevel = 30;

RSI4 = RSIa( C, RSILength ) ;


Buy = RSI4 < RSIBuyLevel;
ApplyStop( stopTypeNBar, stopModeBars, 5 ); //sell 5 days after purchase
Sell = 0;
SellPrice = O; // Sell at open price
 

trash

Well-Known Member
Thanks for that trash. I'm not too familiar with the applystop function parameters and syntax. I tried the following but could not achieve the desired effect. Could you help me out please. Thanks

SetOption( "MaxOpenPositions", 50);
SetPositionSize( 2, spsPercentofequity );

RSILength = 14;

RSIBuyLevel = 30;

RSI4 = RSIa( C, RSILength ) ;


Buy = RSI4 < RSIBuyLevel;
ApplyStop( stopTypeNBar, stopModeBars, 5 ); //sell 5 days after purchase
Sell = 0;
SellPrice = O; // Sell at open price

What desired effect? Am I/are we able to take a look into your brain to see what you consider as desired effect? Probably not.
 
Happy,

I am new to this site and appreciate the offer to help.

Here's the situation:
I want to setup a rotational system, which I have done. But DO NOT want to trade when an ema cross occurs adversely. If enabling a rotation, how do you stop trading or go to cash when a condition occurs such as the cross(ema...?

Thanks TATraderBruce
 

Similar threads