AFL Help needed

VJAY

Well-Known Member
#1
Dear friends/AFL experts,
Please help to modify following afl code.....
Its ma line which change colour with its movement ...eg up-green down-red.flat blue...Now i want to show fig (approximate) of opposite change of colour ...eg...when currently its in green then I want to show the fig (aprox)when it change to blue or red.....is it possible?i need this fig right side of chart where current rate shows...with colour...



_SECTION_BEGIN("MA");
Len = Param("Periods", 30, 10, 60, 10 );
Av = MA(C, Len);
Color = IIf(Av > Ref(Av,-1) AND C > Av, colorGreen, IIf(Av < Ref(Av,-1) AND C < Av, colorRed, colorBlue));
Plot(Av, "", Color, ParamStyle("Av",styleThick, maskAll));
 
Last edited:
#2
Dear friends/AFL experts,
Please help to modify following afl code.....
Its ma line which change colour with its movement ...eg up-green down-red.flat blue...Now i want to show fig (approximate) of opposite change of colour ...eg...when currently its in green then I want to show the fig (aprox)when it change to blue or red.....is it possible?i need this fig right side of chart where current rate shows...with colour...



_SECTION_BEGIN("MA");
Len = Param("Periods", 30, 10, 60, 10 );
Av = MA(C, Len);
Color = IIf(Av > Ref(Av,-1) AND C > Av, colorGreen, IIf(Av < Ref(Av,-1) AND C < Av, colorRed, colorBlue));
Plot(Av, "", Color, ParamStyle("Av",styleThick, maskAll));
Hello Vijay

As long as it is a simple MA the code can be easily done . . .

try this

Code:
Plot(SelectedValue(Ref(C,-Len+1)),"",colorLightGrey,styleDashed,0,0,10);
this code will plot the level which decides if MA is increasing (Av > Ref(Av,-1)) or decreasing (Av < Ref(Av,-1),)
if current price is above this, we have MA increasing, price below this level then MA is decreasing

if you want only the value and don't want the horizontal line then use

Code:
Plot(SelectedValue(Ref(C,-Len+1)),"",colorLightGrey,stylenoline,0,0,10);


if you insist on colors etc then will give it another try . . .

:) Happy
 
Last edited:

VJAY

Well-Known Member
#3
Hello Vijay

As long as it is a simple MA the code can be easily done . . .

try this

Code:
Plot(SelectedValue(Ref(C,-Len+1)),"",colorLightGrey,styleDashed,0,0,10);
this code will plot the level which decides if MA is increasing (Av > Ref(Av,-1)) or decreasing (Av < Ref(Av,-1),)
if current price is above this, we have MA increasing, price below this level then MA is decreasing

if you want only the value and don't want the horizontal line then use

Code:
Plot(SelectedValue(Ref(C,-Len+1)),"",colorLightGrey,stylenoline,0,0,10);


if you insist on colors etc then will give it another try . . .

:) Happy
Thanks happy singh.......its same which i needed ...:thumb:
 

VJAY

Well-Known Member
#4
Dear Happy singh,
I think its not the same which i want....
My requires in image...hope you got it :)

 
#5
hello vijay

Posted the code out of memory, will test that on ami and post the modified version here, maybe during the weekend


:) Happy
 

VJAY

Well-Known Member
#6
hello vijay

Posted the code out of memory, will test that on ami and post the modified version here, maybe during the weekend


:) Happy
Thanks...noproblem ...take your time...for me its need for some testing purpose :)
 
#7
Thanks...noproblem ...take your time...for me its need for some testing purpose :)
Code:
_SECTION_BEGIN("MA");
Len =	Param("Len",20,2,100,1);
Av	 =	MA(C, Len);
Color =	IIf(Av > Ref(Av,-1) AND C > Av, colorGreen, IIf(Av < Ref(Av,-1) AND C < Av, colorRed, colorBlue));
Plot(Av, "", Color, ParamStyle("Av",styleThick, maskAll));

Plot(SelectedValue(Ref(C,-Len)),"",colorBrightGreen,styleDashed,0,0,10); // Slope of MA  up/down 
Plot(SelectedValue(Ref(MA(C,Len-1),-1)),"",colorBlueGrey,  styleDashed,0,0,10); // Price Close  above/below Av
_SECTION_END();
check this . . .


:) Happy
 
Last edited:
#9
thks for the code happy singh ji
We need 2 lines and not one as vijay is using 2 conditions and when the MA line color is blue it will get either red or green from there . . .

Above both the doted lines MA is green, below both it is red in-between blue . . .

btw, only happy is ok . . . no need for ji :D


:) Happy
 

Similar threads