Simple Coding Help - No Promise.

muinali

Well-Known Member
need a small change in afl ,
i want to keep ma same for 12 bars(hourly) in staircase forme

// Example 20-bar Moving average shifted 10 bars into the future past the last bar:
Plot(Close,"Close",colorBlack,styleCandle);
//Plot(MA(Close,20), "Shifted MA", colorRed, styleStaircase, Null, Null, 20);
Plot(MA(Close,20), "Shifted MA", colorRed, styleStaircase,0,0, 10
);

// Note that shift occurs during plotting AND does NOT affect source array
 

manishchan

Well-Known Member
Hi.. looks like right now this thread is flooded with requests. Kindly accommodate when possible.

I want to plot text (HH and LL) instead of circles in an AFL. Can someone help me change these codes of Shapes to Plot text.
try this

PlotText( "HH", ismph, colorBlue );
PlotText( "LL", ismpl, colorGreen );
Thanks Nehal.. but it is not working and throwing error. :(
 

pratapvb

Well-Known Member
Thanks Nehal.. but it is not working and throwing error. :(
in plottext you cannot use an array variable

this means you will have to loop through the array and plot text
to minimize extent of for loop, we plot text only on visible portion of screen

sample code from one of my AFLs....please adjust as required

Code:
	showtext = ParamToggle("Show Text", "No|Yes", 1) ;
	txtclrup = ParamColor("Txt Clr Up", colorBlack) ;
	txtclrdn = ParamColor("Txt Clr Down", colorBlack) ;

if(showtext)
{
	bi = BarIndex() ;
	st = LowestVisibleValue(bi) ;
	ed = HighestVisibleValue(bi) ;

	for (i = st; i <= ed; i++)
	{
		if (Buy[i])
			PlotText(NumToStr(H[i], 8.1), i, H[i]+10, txtclrup) ;
		else if (Short[i])
			PlotText(NumToStr(L[i], 8.1), i, L[i]-10, txtclrup) ;

	}
}
 

Happy Sir

Got the plot correct line is snipped as required ,but the Text is not plotted
Please check this snippet of the code.Here the last line does not plot the text.See attached image(A)


Code:
DayH = TimeFrameGetPrice("H", inDaily, -1)
DayHI =IIf(DayH!=Ref(DayH,-1),Null,DayH);
PriceLineColor=ParamColor("PriceLineColor",ColorRGB(82,82,82));
numbars = LastValue(Cum(Status("barvisible")));
hts  = -33.5;
Plot(DayHI,"YH",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll));
PlotText("YH",LastValue(BarIndex())-(numbars/Hts),DayHI,PriceLineColor);
In this version, the line properties are changeable and the text is plotted,but the lines retrace back to previous day.See attached image B
Code:
DayH = TimeFrameGetPrice("H", inDaily, -1)
DayHI = LastValue (DayH,1);
PriceLineColor=ParamColor("PriceLineColor",ColorRGB(82,82,82));
numbars = LastValue(Cum(Status("barvisible")));
hts  = -33.5;
Plot(DayH,"YH",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll));
PlotText(" YH " ,     LastValue(BarIndex())-(numbars/Hts), DayHI, PriceLineColor);
Please advise,how to get both the things , the line snipped and the text plotted:confused:

Amit both the things are not related to each other :)

Mostly it is plotting the text beyond the right edge of the chart

Adjust the x,y co-ordinates in plot text



Try this

n = 5;//10,15

PlotText(" YH " , LastValue(BarIndex())-n, DayHI*1.001, PriceLineColor);




Happy :)
 

amitrandive

Well-Known Member
Amit both the things are not related to each other :)

Mostly it is plotting the text beyond the right edge of the chart

Adjust the x,y co-ordinates in plot text

Try this

n = 5;//10,15

PlotText(" YH " , LastValue(BarIndex())-n, DayHI*1.001, PriceLineColor);
Happy :)
Happy Sir,
This is not working.Please see the screen shot.It says "The function expects a different argument type here."

 

amitrandive

Well-Known Member
Have you understood post #1594? PlotText expects scalar for x,y coordinates.
trash

I have seen post#1594.If you see the post #1591.I have posted two code options.

My question was regarding that.The second code plots the text correctly,while the first code does not.Even after applying Happy Singh's advice,there is an error as shown in the post # 1597.

Please advice.
 

trash

Well-Known Member
trash

I have seen post#1594.If you see the post #1591.I have posted two code options.

My question was regarding that.The second code plots the text correctly,while the first code does not.Even after applying Happy Singh's advice,there is an error as shown in the post # 1597.

Please advice.
Yeah, you have seen it but have not understood it yet. Two kind of things.

Second code in #1591 will work because DayHI is scalar. That's the reason it is working while first one will not work because well, there DayHI is not scalar.
 

amitrandive

Well-Known Member
Yeah, you have seen it but have not understood it yet. Two kind of things.

Second code in #1591 will work because DayHI is scalar. That's the reason it is working while first one will not work because well, there DayHI is not scalar.
Can you please provide a solution to the first code?
 

Similar threads