Simple Coding Help - No Promise.

KelvinHand

Well-Known Member
hello all,

I am using

Q = 10;
EE = (EMA (c,q) + EMA (O,q))/2 ;
Plot (EE,"EE",IIf(EE <= Ref(EE,-1),colorYellow,colorRed), styleThick);

and getting this

http://tinypic.com/r/117g3d4/8

even in uptrend its giving mixed colors when EE = ref(ee,-1)

how to make it look like this ...

http://www.alphametrix.in/images/learning-img4.jpg

can some one help
Why are given the 1st picture not tally to your formula given period ?
The picture surely not the 10 period but your formula given is 10 period.

Your formula can be re-written as follow:
Q = 10;
EE = EMA ((c+o)/2,q);
Plot (EE,"EE",IIf(EE <= Ref(EE,-1),colorYellow,colorRed), styleThick);

The color did follow what you had written:
When the current bar EMA value is LESS THAN or EQUAL TO previous bar EMA value, then
plot Yellow color
ELSE
the current bar EMA value is GREATER THEN previous bar EMA value, then
plot RED color

So even so your 1st picture not given the right period, but the logic still follow above very well.
So where did you see "even in uptrend its giving mixed colors when EE = ref(ee,-1)"
 
Last edited:

niftyoption

Well-Known Member
Dear Kelvin Hand Sir,

could you please write code for .... fill color between two or three moving averages .... color light gray or any color.... moving averages change facility :)
 
hello


i need an afl which plots and scans the following conditions


1) three consecutive higher closes w.r.t to previous day
and

2) three consecutive lower closes w.rt to previous day

i also request a param option in this to change parameters from 3 to 10 in steps of 1


rgds



sumit


anyone please help for this
 
Can anybody please confirm whether the below code is correct.

Code:
Buy=Cross(Close,Study( "RE" ));
Sell = Cross( Study( "SU" ), Close);
Short=Sell;
Cover=Buy;

PlotShapes( Buy * shapeUpTriangle + Sell * shapeDownTriangle, IIf( Buy, colorGreen, colorRed ), Offset = -1);
 
Now AFL with RNs working given below
--------------
_SECTION_BEGIN("PreDHLCDayHLRN");
x=LastVisibleValue(DateNum());
Hor0 = Param("Hor0",900,0,1368,1);
Ver0 = Param("Ver0",30,0,768,1);

Cond=BarsSince(DateNum()<x);
y=Ref(DateNum(),-Cond);
Cond1=BarsSince(DateNum()<LastValue(y));
z=Cond1-Cond;
Hi0=HHV(H,Cond);
Hi0bar=HHVBars(H,Cond);

x20=BarCount-LastValue(Cond);
x21=BarCount-1;
y20=LastVisibleValue(Hi0);
y21=y20;
Line2 = LineArray( x20, y20, x21, y21, 1 );
Plot( Line2, "day high line", colorOrange,styleThick|styleNoTitle);

Li0=LLV(L,Cond);
Li0bar=LLVBars(L,Cond);

x30=BarCount-LastValue(Cond);
x31=BarCount-1;
y30=LastVisibleValue(Li0);
y31=y30;
Line3 = LineArray( x30, y30, x31, y31, 1 );
Plot( Line3, "day low line", colorTurquoise,styleThick|styleNoTitle );

Hi=Ref(HHV(H,z),-Cond);
Hibar=Ref(HHVBars(H,z),-Cond)+Cond;
x0=BarCount-1-LastValue(Hibar);
x1=BarCount-1;
y0=LastValue(Hi);
y1=y0;
Line = LineArray( x0, y0, x1, y1, 1 );
Plot( Line, "high line", ParamColor("high line", colorGreen),styleThick|styleNoTitle );

pc=Ref(Close,-Cond);

x10=BarCount-1-LastValue(Cond);
x11=BarCount-1;
y10=LastValue(pc);
y11=y10;

Line1=LineArray( x10, y10, x11, y11, 1 );
Plot( Line1, "Close line", ParamColor("close line", colorWhite),styleThick|styleNoTitle );

Lo=Ref(LLV(L,z),-Cond);
Lobar=Ref(LLVBars(L,z),-Cond)+Cond;

x00=BarCount-1-LastValue(Lobar);
x01=BarCount-1;
y00=LastValue(Lo);
y01=y00;

Line11=LineArray(x00,y00,x01,y01,1);
Plot(Line11,"Low Line",ParamColor("Low line", colorBlue),styleThick|styleNoTitle);

yh = int(Max(y0,y20)/50)*50;
yl = int(Min(y00,y30)/50)*50;

i=yl;
while( i>= yl AND i<=yh )
{i1 = i;
Linex=LineArray(x0,i,x1,i1);
Plot(Linex,"",colorGold,styleThick|styleNoTitle);
i=i+50;
}
_SECTION_END();
--------------
Can we plot the nifty spot chart in shadow like we are able to see in the charts provided by the icharts we can can see nifty futures chart as we see and we able to see the spot chart like shadow
 

casoni

Well-Known Member
Hello ,
Yes , Here's the example [ 2 scripts]
.NSEI And NIFTY_F1
you can change script from parameter window also and you can add as many as you like depends on your [ pc / laptop ] screen size :)

tickerA = ParamStr( "TickerA", ".NSEI" );
tickerB = ParamStr( "TickerB", "NIFTY_F1" );


PlotForeign( tickerA, "\nChart of "+tickerA,ParamColor( "Price ColorA", colorWhite ), styleLine |styleOwnScale|styleNoLabel);
PlotForeign( tickerB, "\nChart of "+tickerB,ParamColor( "Price ColorB", colorGreen ), styleLine |styleOwnScale|styleNoLabel);

hope this is what you were looking for
 
Why are given the 1st picture not tally to your formula given period ?
The picture surely not the 10 period but your formula given is 10 period.

Your formula can be re-written as follow:
Q = 10;
EE = EMA ((c+o)/2,q);
Plot (EE,"EE",IIf(EE <= Ref(EE,-1),colorYellow,colorRed), styleThick);

The color did follow what you had written:
When the current bar EMA value is LESS THAN or EQUAL TO previous bar EMA value, then
plot Yellow color
ELSE
the current bar EMA value is GREATER THEN previous bar EMA value, then
plot RED color

So even so your 1st picture not given the right period, but the logic still follow above very well.
So where did you see "even in uptrend its giving mixed colors when EE = ref(ee,-1)"
Hi you are right as both pic are not mine... anyway that not the point here
as you said to rewrite the code like EE = EMA ((c+o)/2,q);
can you help me on other line ie.,
Plot (EE,"EE",IIf(EE <= Ref(EE,-1),colorYellow,colorRed), styleThick);

so that one can get the line as shown in the second pic above..:thumb:
 

Similar threads