Pl. correct Amibroker code which distorts chart view.

bharatk8

Active Member
#1
Hi
My code has Monthly,Weekly,Daily MTF lines.These MTF lines compress chart view.I have tried various scale options to correct this but theses attempts have failed to deliver desired results.Pl. suggest ways to plot only those MTF lines which are close to(40 pips below/above) current bar only.
_SECTION_BEGIN( "Monthly BB" );

TFm = inMonthly ;

TimeFrameSet( TFm );

ShowBBm9F = ParamToggle( "BB9 MTFm F", "Hide|Show", 1 );
ShowBBm9L = ParamToggle( "BB9 MTFm L", "Hide|Show", 1 );
PMTFm9 = Param( "Periom9 MTFm", 9, 2, 30, 1 );
WMTFm9 = Param( "Width9 MTFm", 1.5, 0, 10, 0.05 );
ShowBBm20F = ParamToggle( "BB20 MTFm F", "Hide|Show", 1 );
ShowBBm20L = ParamToggle( "BB20 MTFm L", "Hide|Show", 1 );
PMTFm20 = Param( "Periom20 MTFm", 20, 2, 30, 1 );
WMTFm20 = Param( "Width20 MTFm", 2, 0, 10, 0.05 );
Mm9 = WMA( C, PMTFm9 );
sdm9 = StDev( C, PMTFm9 );
Topm9 = Mm9 + WMTFm9 * sdm9;
Botm9 = Mm9 - WMTFm9 * sdm9;
Mm20 = WMA( C, PMTFm20 );
sdm20 = StDev( C, PMTFm20 );
Topm20 = Mm20 + WMTFm20 * sdm20;
Botm20 = Mm20 - WMTFm20 * sdm20;

TimeFrameRestore();

Mm9Fm = TimeFrameExpand( Mm9, TFm, expandFirst );
TP9Fm = TimeFrameExpand( TOPm9, TFm, expandFirst );
BT9Fm = TimeFrameExpand( BOTm9, TFm, expandFirst );
Mm20Fm = TimeFrameExpand( Mm20, TFm, expandFirst );
TP20Fm = TimeFrameExpand( TOPm20, TFm, expandFirst );
BT20Fm = TimeFrameExpand( BOTm20, TFm, expandFirst );
Mm9lm = TimeFrameExpand( Mm9, TFm, expandLast );
TP9lm = TimeFrameExpand( TOPm9, TFm, expandLast );
BT9lm = TimeFrameExpand( BOTm9, TFm, expandLast );
Mm20lm = TimeFrameExpand( Mm20, TFm, expandLast );
TP20lm = TimeFrameExpand( TOPm20, TFm, expandLast );
BT20lm = TimeFrameExpand( BOTm20, TFm, expandLast );
if ( ShowBBm9F )
//Plot( Mm9Fm, "MID BANm9 monthly First", colorOrange, styleLine| styleDashed | styleNoRescale );//styleDots |
if ( ShowBBm9F )
//Plot( TP9Fm, "TOP BANm9 monthly First", colorDarkRed, styleLine| styleDashed | styleNoRescale );//styleDots|
if ( ShowBBm9F )
//Plot( BT9Fm, "BOT BANm9 monthly First", colorDarkOliveGreen, styleLine | styleDashed| styleNoRescale );//styleDots|styleDashed |
if ( ShowBBm9L )
//Plot( Mm9lm, "MID BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm9L )
//Plot( TP9lm, "TOP BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm9L )
//Plot( BT9lm, "BOT BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20F )
//Plot( Mm20Fm, "MID BANm20 monthly First", colorBrown, styleLine | styleNoRescale );//styleDots |
if ( ShowBBm20F )
//Plot( TP20Fm, "TOP BANm20 monthly First", colorBrown, styleLine | styleNoRescale );
if ( ShowBBm20F )
//Plot( BT20Fm, "BOT BANm20 monthly First", colorBrown, styleLine | styleNoRescale );//styleDots |
if ( ShowBBm20L )
//Plot( Mm20lm, "MID BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20L )
//Plot( TP20lm, "TOP BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20L )
//Plot( BT20lm, "BOT BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
 

amitrandive

Well-Known Member
#2
Hi
My code has Monthly,Weekly,Daily MTF lines.These MTF lines compress chart view.I have tried various scale options to correct this but theses attempts have failed to deliver desired results.Pl. suggest ways to plot only those MTF lines which are close to(40 pips below/above) current bar only.
_SECTION_BEGIN( "Monthly BB" );

TFm = inMonthly ;

TimeFrameSet( TFm );

ShowBBm9F = ParamToggle( "BB9 MTFm F", "Hide|Show", 1 );
ShowBBm9L = ParamToggle( "BB9 MTFm L", "Hide|Show", 1 );
PMTFm9 = Param( "Periom9 MTFm", 9, 2, 30, 1 );
WMTFm9 = Param( "Width9 MTFm", 1.5, 0, 10, 0.05 );
ShowBBm20F = ParamToggle( "BB20 MTFm F", "Hide|Show", 1 );
ShowBBm20L = ParamToggle( "BB20 MTFm L", "Hide|Show", 1 );
PMTFm20 = Param( "Periom20 MTFm", 20, 2, 30, 1 );
WMTFm20 = Param( "Width20 MTFm", 2, 0, 10, 0.05 );
Mm9 = WMA( C, PMTFm9 );
sdm9 = StDev( C, PMTFm9 );
Topm9 = Mm9 + WMTFm9 * sdm9;
Botm9 = Mm9 - WMTFm9 * sdm9;
Mm20 = WMA( C, PMTFm20 );
sdm20 = StDev( C, PMTFm20 );
Topm20 = Mm20 + WMTFm20 * sdm20;
Botm20 = Mm20 - WMTFm20 * sdm20;

TimeFrameRestore();

Mm9Fm = TimeFrameExpand( Mm9, TFm, expandFirst );
TP9Fm = TimeFrameExpand( TOPm9, TFm, expandFirst );
BT9Fm = TimeFrameExpand( BOTm9, TFm, expandFirst );
Mm20Fm = TimeFrameExpand( Mm20, TFm, expandFirst );
TP20Fm = TimeFrameExpand( TOPm20, TFm, expandFirst );
BT20Fm = TimeFrameExpand( BOTm20, TFm, expandFirst );
Mm9lm = TimeFrameExpand( Mm9, TFm, expandLast );
TP9lm = TimeFrameExpand( TOPm9, TFm, expandLast );
BT9lm = TimeFrameExpand( BOTm9, TFm, expandLast );
Mm20lm = TimeFrameExpand( Mm20, TFm, expandLast );
TP20lm = TimeFrameExpand( TOPm20, TFm, expandLast );
BT20lm = TimeFrameExpand( BOTm20, TFm, expandLast );
if ( ShowBBm9F )
//Plot( Mm9Fm, "MID BANm9 monthly First", colorOrange, styleLine| styleDashed | styleNoRescale );//styleDots |
if ( ShowBBm9F )
//Plot( TP9Fm, "TOP BANm9 monthly First", colorDarkRed, styleLine| styleDashed | styleNoRescale );//styleDots|
if ( ShowBBm9F )
//Plot( BT9Fm, "BOT BANm9 monthly First", colorDarkOliveGreen, styleLine | styleDashed| styleNoRescale );//styleDots|styleDashed |
if ( ShowBBm9L )
//Plot( Mm9lm, "MID BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm9L )
//Plot( TP9lm, "TOP BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm9L )
//Plot( BT9lm, "BOT BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20F )
//Plot( Mm20Fm, "MID BANm20 monthly First", colorBrown, styleLine | styleNoRescale );//styleDots |
if ( ShowBBm20F )
//Plot( TP20Fm, "TOP BANm20 monthly First", colorBrown, styleLine | styleNoRescale );
if ( ShowBBm20F )
//Plot( BT20Fm, "BOT BANm20 monthly First", colorBrown, styleLine | styleNoRescale );//styleDots |
if ( ShowBBm20L )
//Plot( Mm20lm, "MID BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20L )
//Plot( TP20lm, "TOP BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20L )
//Plot( BT20lm, "BOT BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
Price should appear at the top most for view to appear correctly.
Also removed the "//" in the code ,which was not plotting earlier


Nifty-I Daily


Code:
_SECTION_BEGIN("Price");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
_SECTION_BEGIN( "Monthly BB" );

TFm = inMonthly ;

TimeFrameSet( TFm );

ShowBBm9F = ParamToggle( "BB9 MTFm F", "Hide|Show", 1 );
ShowBBm9L = ParamToggle( "BB9 MTFm L", "Hide|Show", 1 );
PMTFm9 = Param( "Periom9 MTFm", 9, 2, 30, 1 );
WMTFm9 = Param( "Width9 MTFm", 1.5, 0, 10, 0.05 );
ShowBBm20F = ParamToggle( "BB20 MTFm F", "Hide|Show", 1 );
ShowBBm20L = ParamToggle( "BB20 MTFm L", "Hide|Show", 1 );
PMTFm20 = Param( "Periom20 MTFm", 20, 2, 30, 1 );
WMTFm20 = Param( "Width20 MTFm", 2, 0, 10, 0.05 );
Mm9 = WMA( C, PMTFm9 );
sdm9 = StDev( C, PMTFm9 );
Topm9 = Mm9 + WMTFm9 * sdm9;
Botm9 = Mm9 - WMTFm9 * sdm9;
Mm20 = WMA( C, PMTFm20 );
sdm20 = StDev( C, PMTFm20 );
Topm20 = Mm20 + WMTFm20 * sdm20;
Botm20 = Mm20 - WMTFm20 * sdm20;

TimeFrameRestore();

Mm9Fm = TimeFrameExpand( Mm9, TFm, expandFirst );
TP9Fm = TimeFrameExpand( TOPm9, TFm, expandFirst );
BT9Fm = TimeFrameExpand( BOTm9, TFm, expandFirst );
Mm20Fm = TimeFrameExpand( Mm20, TFm, expandFirst );
TP20Fm = TimeFrameExpand( TOPm20, TFm, expandFirst );
BT20Fm = TimeFrameExpand( BOTm20, TFm, expandFirst );
Mm9lm = TimeFrameExpand( Mm9, TFm, expandLast );
TP9lm = TimeFrameExpand( TOPm9, TFm, expandLast );
BT9lm = TimeFrameExpand( BOTm9, TFm, expandLast );
Mm20lm = TimeFrameExpand( Mm20, TFm, expandLast );
TP20lm = TimeFrameExpand( TOPm20, TFm, expandLast );
BT20lm = TimeFrameExpand( BOTm20, TFm, expandLast );
if ( ShowBBm9F )
Plot( Mm9Fm, "MID BANm9 monthly First", colorOrange, styleLine| styleDashed | styleNoRescale );//styleDots |
if ( ShowBBm9F )
Plot( TP9Fm, "TOP BANm9 monthly First", colorDarkRed, styleLine| styleDashed | styleNoRescale );//styleDots|
if ( ShowBBm9F )
Plot( BT9Fm, "BOT BANm9 monthly First", colorDarkOliveGreen, styleLine | styleDashed| styleNoRescale );//styleDots|styleDashed |
if ( ShowBBm9L )
Plot( Mm9lm, "MID BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm9L )
Plot( TP9lm, "TOP BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm9L )
Plot( BT9lm, "BOT BANm9 monthly Last", colorOrange, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20F )
Plot( Mm20Fm, "MID BANm20 monthly First", colorBrown, styleLine | styleNoRescale );//styleDots |
if ( ShowBBm20F )
Plot( TP20Fm, "TOP BANm20 monthly First", colorBrown, styleLine | styleNoRescale );
if ( ShowBBm20F )
Plot( BT20Fm, "BOT BANm20 monthly First", colorBrown, styleLine | styleNoRescale );//styleDots |
if ( ShowBBm20L )
Plot( Mm20lm, "MID BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20L )
Plot( TP20lm, "TOP BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
if ( ShowBBm20L )
Plot( BT20lm, "BOT BANm20 monthly Last", colorBrown, styleLine | styleDots | styleThick | styleNoRescale );
 

bharatk8

Active Member
#3
Dear Amit

Thanks a lot for prompt guidance.

Solution given by you has worked like charm

Pl. suggest tweaking of cloud code as it also distorts chart view.

Code:

bwclr = IIf( ( TP9Fw < TP9Lw ), colorOrange, IIf( ( TP9Fw > TP9Lw ) , colorPink, colorLightGrey ) );
PlotOHLC( TP9Fw, TP9Lw , TP9Fw , TP9Lw , "", bwclr, styleCloud ) ;
 

amitrandive

Well-Known Member
#4
Dear Amit

Thanks a lot for prompt guidance.

Solution given by you has worked like charm

Pl. suggest tweaking of cloud code as it also distorts chart view.

Code:

bwclr = IIf( ( TP9Fw < TP9Lw ), colorOrange, IIf( ( TP9Fw > TP9Lw ) , colorPink, colorLightGrey ) );
PlotOHLC( TP9Fw, TP9Lw , TP9Fw , TP9Lw , "", bwclr, styleCloud ) ;
Please post complete code, parameters not defined on my side.
 

bharatk8

Active Member
#5
I have tried following options mentioned in manual.But I have not received desired view.I have to keep adjusting Yaxis values in parameter window otherwise sometimes I can can hardly see candle.(see image)Pl. suggest necessary tweaking options.

Code 1:
mid1 = WMA( C, Period1 );
sd1 = StDev( C, Period1 );
Top1 = mid1 + Width1 * sd1;
Bot1 = mid1 - Width1 * sd1;
minimum = HighestVisibleValue( .99 * Bot1 );
maximum = LowestVisibleValue( 1.01 * Top1 );

HHm = ( TimeFrameGetPrice( "H", inMonthly, -1 ) ) ;
Plot( HHm, "High", colorBlack, styleDots, Minimum, Maximum);

Code 2:

Plot(IIf(HHm< HighestVisibleValue(Top1) AND HHm > LowestVisibleValue(Bot1),LL,Null ) , "HHm", colorBlack, styleLine | styleDots | styleThick );

P.S.I am not able to upload code and chart image due to some uploading issue.
 
Last edited:

bharatk8

Active Member
#6
Pl. see image.

Chart on left is a view of my original AFL with styleNoReScale.I have changed yaxis parameters(minimum/maximum values of yaxis) for proper view.

Chart on right is a view of AFL with styleOwnScale.This AFL gives a view which is easy on eye and I do not need to change yaxis parameters for view.

But on close inspection,it becomes apparent that,MTF lines and cloud plots are not positioned correctly with reference to close of candle.

Pl. help

P.S. I am not able to upload files due to net issue.
 
Last edited:

amitrandive

Well-Known Member
#8
Pl. see image.

Chart on left is a view of my original AFL with styleNoReScale.I have changed yaxis parameters(minimum/maximum values of yaxis) for proper view.

Chart on right is a view of AFL with styleOwnScale.This AFL gives a view which is easy on eye and I do not need to change yaxis parameters for view.

But on close inspection,it becomes apparent that,MTF lines and cloud plots are not positioned correctly with reference to close of candle.

Pl. help

P.S. I am not able to upload files due to net issue.
Please use "#paste code here#" to paste such super super huge codes.

Just don't know how you can trade with this AFL.

Use styleNorescale and styleNolabel ,wherever you want.

Most of the labels interfering with each other while plotting and causing this.

That part you have to do it yourself.

Or any senior can comment/modify.



 

bharatk8

Active Member
#9
Hi

After all sort of experiments,view of chart has improved to some extent.But I think i should go for "ZOOM RECENT BARS".This feature is available in several softwares/terminals.May I have code for it?