Help shading between lines

#1
I have a very simple oscillator I have been playing around with and I would like to ask for some help...PLEASE

I am a newbie to Amibroker and this may be a simple fix but I am struggling
The indicator works fine and in fact is pretty nice but I want more...LOL

One, I would like to shade (cloud) between the two lines when they separate.
Two I would love to print buy and sell boxes...I can do without this if referencing the price is difficult.

Thanks in advance for any kind soul who can help

Code:

_SECTION_BEGIN("Price Oscillator");

m = Param("Periods", 10, 5, 20, 1 );
n = Param("Average", 4, 3, 10, 1 );

Var2=(High+Low+Close*2)/4;
Var3=EMA(Var2,m);
Var4=StDev(Var2,m);
Var5=(Var2-Var3)*100/IIf(Var4==0,1,Var4);
Var6=EMA(Var5,n);
Var7=EMA(Var6,n);
WW=(EMA(Var7,m)+100)/2-4;
MM=HHV(WW,n);

Plot(ww, "WW", colorAqua, 1+4);
Plot(mm, "MM", colorYellow, styleDashed |styleThick, 1+4);


//Buy=IIf(ww>Ref(ww,-1) AND Ref(ww,-1)<Ref(ww,-2) AND ww<50,20,0);
//PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone) ,colorBrightGreen);
//Sell=IIf(ww<Ref(ww,-1) AND Ref(ww,-1)>Ref(ww,-2) AND ww>50,20,0);
//PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed);

_SECTION_END();
 
#2
I tried again for two hours with no luck. I read all I could about AFL code and I am having a hard time. My brain still works in easylanguage but it's getting better. If nobody can help maybe you could refer me to another board that has people that can help me.

Thanks
 

HULK

Active Member
#3
Mini

I think your Period and average what you had mentioned in AFL is not correct has to be modify.
Any way find enclosed the AFL with your Parameter with both your condition.

1) Shade (cloud) between the two lines when they separate.
2) Print buy and sell Arrow.

_SECTION_BEGIN("Price Oscillator");

m = Param("Periods", 10, 5, 20, 1 );
n = Param("Average", 4, 3, 10, 1 );

Var2=(High+Low+Close*2)/4;
Var3=EMA(Var2,m);
Var4=StDev(Var2,m);
Var5=(Var2-Var3)*100/IIf(Var4==0,1,Var4);
Var6=EMA(Var5,n);
Var7=EMA(Var6,n);
WW=(EMA(Var7,m)+100)/2-4;
MM=HHV(WW,n);

Plot(ww, "WW", colorAqua, 1+4);
Plot(mm, "MM", colorYellow, styleDashed |styleThick, 1+4);

PlotOHLC( WW, WW, MM, MM, "", IIf(WW > MM,colorDarkYellow, colorDarkRed),styleNoLabel|styleCloud );


Buy=IIf(ww>Ref(ww,-1) AND Ref(ww,-1)<Ref(ww,-2) AND ww<50,20,0);
PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone) ,colorBrightGreen);
Sell=IIf(ww<Ref(ww,-1) AND Ref(ww,-1)>Ref(ww,-2) AND ww>50,20,0);
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed);

_SECTION_END();
 
#5
Mini

I think your Period and average what you had mentioned in AFL is not correct has to be modify.
Any way find enclosed the AFL with your Parameter with both your condition.

1) Shade (cloud) between the two lines when they separate.
2) Print buy and sell Arrow.

_SECTION_BEGIN("Price Oscillator");

m = Param("Periods", 10, 5, 20, 1 );
n = Param("Average", 4, 3, 10, 1 );

Var2=(High+Low+Close*2)/4;
Var3=EMA(Var2,m);
Var4=StDev(Var2,m);
Var5=(Var2-Var3)*100/IIf(Var4==0,1,Var4);
Var6=EMA(Var5,n);
Var7=EMA(Var6,n);
WW=(EMA(Var7,m)+100)/2-4;
MM=HHV(WW,n);

Plot(ww, "WW", colorAqua, 1+4);
Plot(mm, "MM", colorYellow, styleDashed |styleThick, 1+4);

PlotOHLC( WW, WW, MM, MM, "", IIf(WW > MM,colorDarkYellow, colorDarkRed),styleNoLabel|styleCloud );


Buy=IIf(ww>Ref(ww,-1) AND Ref(ww,-1)<Ref(ww,-2) AND ww<50,20,0);
PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone) ,colorBrightGreen);
Sell=IIf(ww<Ref(ww,-1) AND Ref(ww,-1)>Ref(ww,-2) AND ww>50,20,0);
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed);

_SECTION_END();
Thank you very much. I still don't quite understand the logic on the line you added:

PlotOHLC( WW, WW, MM, MM, "", IIf(WW > MM,colorDarkYellow, colorOrange),styleNoLabel|styleCloud );
But it works like I want

Thanks again and I will get better at AFL and hopefully return the favor
 
#7
_SECTION_BEGIN("Price Oscillator");

m = Param("Periods", 10, 5, 20, 1 );
n = Param("Average", 4, 3, 10, 1 );

Var2=(High+Low+Close*2)/4;
Var3=EMA(Var2,m);
Var4=StDev(Var2,m);
Var5=(Var2-Var3)*100/IIf(Var4==0,1,Var4);
Var6=EMA(Var5,n);
Var7=EMA(Var6,n);
WW=(EMA(Var7,m)+100)/2-4;
MM=HHV(WW,n);

Plot(ww, "WW", colorAqua, 1+4);
Plot(mm, "MM", colorYellow, styleDashed |styleThick, 1+4);

PlotOHLC( WW, WW, MM, MM, "", IIf(WW > MM,colorDarkYellow, colorDarkRed),styleNoLabel|styleCloud );

SetGradientFill( colorGreen /*top*/, colorRed /*bottom*/, 50 /*baseline level*/, GetChartBkColor() /*baseline color */);
Plot( ww, "ww", colorAqua, styleLine | styleGradient|styleNoLabel, Null, Null, 0, -1,2 );




Buy=IIf(ww>Ref(ww,-1) AND Ref(ww,-1)<Ref(ww,-2) AND ww<50,20,0);
PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone) ,colorBrightGreen);
Sell=IIf(ww<Ref(ww,-1) AND Ref(ww,-1)>Ref(ww,-2) AND ww>50,20,0);
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed);

_SECTION_END();



Plot(00,"",colorAqua,styleLine|styleDashed);
Plot(50,"",colorTan,styleLine);
Plot(100,"",colorAqua,styleLine|styleDashed);



//=========================

SAME CODE WITH SOME GRADIENT FILL INCLUDED

//=====================================
 

Attachments

Similar threads