any help

#1
i tried to put prices on rsi indicator
and every thing goes perfect
but one thing i cant do it
i need to put price narrow to peaks and trough
any help ????
....................................
_SECTION_BEGIN("RSI styleClipMinMax");
SetChartOptions(0,0,chartGrid20|chartGrid50|chartGrid80);
periods = Param( "Periods", 12, 1, 200, 1 );
Plot( RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
maxClip = Param( "maxClip", 80, 1, 100, 1 );
minClip = Param( "minClip", 20, 1, 100, 1 );
r = RSI(periods);
PlotOHLC( r,r,50,r, "", IIf( r > 50, colorRed, colorBrightGreen ), styleCloud | styleNoLabel | styleClipMinMax, minClip, maxClip );
Overbought = 80 ;
Oversold =20 ;
Center = 50 ;

Plot(Overbought, "",colorRed) ;
Plot(Oversold, "",colorGreen) ;
Plot(Center, "",colorBlack, styleDashed) ;

_SECTION_END();


_SECTION_BEGIN("Show Values at H&L");

n=Param("Values back",20,1,200,1);
p=Param("zig %",5,1,100,0.1);
fraction1= IIf(StrRight(Name(),3) == "",1,4);
fraction2= IIf(StrRight(Name(),3) == "",1,4);

ero = Param("ATR multiple", 2.8, 0.5, 200, 0.1 )*Param("ATR period", 10, 3, 50 );
ss=Peak(r,ero);
s=Trough(r,ero);
dist=IIf(r>Ref(ss,-1),1,IIf(r<Ref(s,-1),-3,0.5));
for( i =0; i < n; i++)
{
PlotText(""+LastValue(Peak(C,p,i),True),BarCount-1-LastValue(PeakBars(C,p,i)),LastValue(fraction1,True)+LastValue(Peak(r,fraction1,i),False),ParamColor("HIGHColor", colorBrightGreen ));
PlotText(""+LastValue(Trough(C,p,i),True),BarCount-1-LastValue(TroughBars(C,p,i)),LastValue(Trough(r,fraction2,i),False)-LastValue(fraction2,True),ParamColor("LOWColor", colorBrightGreen ));
}


_SECTION_END();

 

KelvinHand

Well-Known Member
#3
The syntax of plottext is:
PlotText( ''text'', x, y, color, bkcolor = colorDefault, yoffset = 0 )

If this is the indicator of RSI, why you want reference X to Price ?


PlotText(""+LastValue(Peak(C,p,i),True),
BarCount-1-LastValue(PeakBars(C,p,i)),
LastValue(fraction1,True)+LastValue(Peak(r,fraction1,i),False),
ParamColor ("HIGHColor", colorBrightGreen ));

PlotText(""+LastValue(Trough(C,p,i),True),
BarCount-1-LastValue(TroughBars(C,p,i)),
LastValue(Trough(r,fr action2,i),False)-LastValue(fraction2,True),
ParamColor("LOWColor", colorBrightGreen ));


Did you check the reference to Price to reference to RSI is at the same time (x) location ????
 
Last edited:

manoj2012

On Probation
#6
Hi Friends,

I am new to Amibroker ... recently installed it on my PC (OS is XP) and also on my Laptop (OS is Windows7) ......I tried to import data (downloaded from getbhavcopy utility) ...... it works perfectly well on my PC with XP system but it is not being imported in Amibroker on my Laptop with system Windows7.

Experts please advise

Thanx
 
#8
the syntax of plottext is:
Plottext( ''text'', x, y, color, bkcolor = colordefault, yoffset = 0 )

if this is the indicator of rsi, why you want reference x to price ?


Plottext(""+lastvalue(peak(c,p,i),true),
barcount-1-lastvalue(peakbars(c,p,i)),
lastvalue(fraction1,true)+lastvalue(peak(r,fraction1,i),false),
paramcolor ("highcolor", colorbrightgreen ));

plottext(""+lastvalue(trough(c,p,i),true),
barcount-1-lastvalue(troughbars(c,p,i)),
lastvalue(trough(r,fr action2,i),false)-lastvalue(fraction2,true),
paramcolor("lowcolor", colorbrightgreen ));


did you check the reference to price to reference to rsi is at the same time (x) location ????
what is this condition, what you want in afl ?
just i need to adjust prices places above peaks & below trough
because some prices not organized (shown in chart)
thanks in advance
 

trash

Well-Known Member
#9
Your code in post #1 is just awful.

It is much simpler.
You just have to loop visible chart area and compare peak and through with RSI variable. That's it.

So here is correction.

Code:
_SECTION_BEGIN( "RSI styleClipMinMax" );
// modified by trash
Version( 5.90 );

periods = Param( "Periods", 12, 1, 200, 1 );
maxClip = Param( "maxClip", 80, 1, 100, 1 );
minClip = Param( "minClip", 20, 1, 100, 1 );

r = RSIa( C, periods );

GraphXSpace = 8;
SetChartOptions( 1, chartShowDates, 0, 0, 0, 0 );
Plot( r, "RSI",
      ParamColor( "Color", colorCycle ),
      ParamStyle( "Style" ),
      Null, Null, 0, 0, width = -20 );
//
PlotOHLC( r, r, 50, r, "",
          IIf( r > 50, colorRed, colorBrightGreen ),
          styleCloud | styleNoLabel | styleClipMinMax,
          minClip, maxClip );
//
PlotGrid( Overbought = 80, colorRed, 1, 2, True );
PlotGrid( Oversold = 20, colorGreen, 1, 2, True );
PlotGrid( Center = 50, colorBlack, 3, 2, True );

_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} - {{DATE}}  {{VALUES}}" ) );
_SECTION_END();

_SECTION_BEGIN("Show Values at H&&L");
// by  trash
Version( 5.90 );

change = Param( "%Change", 5, 1, 100, 0.1 );

pk = Peak( r, change, 1 );
th = Trough( r, change, 1 ); 

offset = Param( "Y-offset", 10, 0, 50, 1 );
if ( ParamToggle( "Display Text", "OFF|ON", 1 ) ) {
    font = "Arial";
    fontsize = 8;

    bi = BarIndex();
    start = FirstVisibleValue( bi );
    end = LastVisibleValue( bi );
    for ( i = start; i <= end; i++ ) {
        if ( r[i] == pk[i] )
            PlotTextSetFont( StrFormat( "%1.1f", pk[ i ] ),
                             font, fontsize,
                             i, pk[ i ],
                             colorGreen, colorDefault, offset );
        //
        if ( r[i] == th[i] )
            PlotTextSetFont( StrFormat( "%1.1f", th[ i ] ),
                             font, fontsize,
                             i, th[ i ],
                             colorRed, colorDefault, -(offset+fontsize) );
    }
}
_SECTION_END();
So it will look properly then.

 

Similar threads