Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Thanks Amit for supporting once again ..

sorry for not providing buy & sell conditions as it skipped from mind .;)

If Possible :- 2 Buy Signal ( Differently Colored )

Buy 1 if price closed & trade above Donchian 144 upper band .

Buy 2 if price closed & trade above Donchian 720 upper band .

Sell1 if price closed & trade below Donchian 144 lower band .

Sell2 if price closed & trade below Donchian 720 lower band .

Addition With alert :)
The basic code.Not very attractive.
Needs to be refined by an expert.

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("DONCHAIN1");
// Plots a 20 period Donchian channel

pds=144;
DonchianUpper =HHV(Ref(C,-1),pds);
DonchianLower = LLV(Ref(C,-1),pds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


Plot(DonchianUpper,"DU",colorGreen,styleLine);
Plot(DonchianMiddle,"DM",colorViolet,styleNoDraw);
Plot(DonchianLower,"DL",colorRed,styleLine);

_SECTION_BEGIN("DONCHAIN2");
// Plots a 20 period Donchian channel

pds1=720;
DonchianUpper1 =HHV(Ref(C,-1),pds1);
DonchianLower1 = LLV(Ref(C,-1),pds1);
DonchianMiddle1 = (DonchianUpper1+DonchianLower1)/2;


Plot(DonchianUpper1,"DU1",colorDarkRed,styleThick);
Plot(DonchianMiddle1,"DM1",colorWhite,styleNoDraw);
Plot(DonchianLower1,"DL1",colorRed,styleThick);
Buy=Cross(C,DonchianUpper);
Buy1=Cross(C,DonchianUpper1);
Sell=Cross(DonchianLower,C);
Sell1=Cross(DonchianLower1,C);
Buy=Buy OR Buy1;
Sell=Sell OR Sell1;
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
 PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
PopupWindow("Buy : " + FullName(),"BUY", 5, 640*mtRandom(), 480*mtRandom());
PopupWindow("Sell : " + FullName(),"SELL", 5, 640*mtRandom(), 480*mtRandom());
 

chintan786

Well-Known Member
Hi All,

I want to plot OI in intraday chart in line Format. But condition is:

1. colour of line should changes to Red if value is less then previous one and

2. Changes to Green if value is greater then previous one.

Regards,
Chintan
 
Last edited:
Can Any one help this afl for writing polt text in tittle like CPRbuy, CPR sell and another bar reversal setup.

/*Color Coded Short Term Reversal Signals
by Larry Lovrencic

Some of the colors may need to change depending on your choice of background
color.
This has been coded for a white background*/

/*Closing Price Reversals*/
CPRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<ref(H,-1) AND L<ref(L,-1) AND
C>ref(C,-1);
CPRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H>ref(H,-1) AND L>ref(L,-1) AND
C<ref(C,-1);

/*Hook Reversals*/
HRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<ref(H,-1) AND L>ref(L,-1);
HRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H<ref(H,-1) AND L>ref(L,-1);

/*Island Reversals*/
IRbuy=ref(L,-2)>ref(H,-1) AND L>ref(H,-1);
IRsell=ref(H,-2)<ref(L,-1) AND H<ref(L,-1);

/*Key Reversals*/
KRbuy=O<ref(C,-1) AND L<ref(L,-1) AND C>ref(H,-1);
KRsell=O>ref(C,-1) AND H>ref(H,-1) AND C<ref(L,-1);

/*Open Close Reversals*/
OCRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<ref(H,-1) AND L<ref(L,-1) AND
C<ref(C,-1);
OCRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H>ref(H,-1) AND L>ref(L,-1) AND
C>ref(C,-1);

/*Pivot Point Reversals*/
PPRbuy=ref(L,-1)<ref(L,-2) AND ref(L,-1)<L AND C>ref(H,-1);
PPRsell=ref(H,-1)>ref(H,-2) AND ref(H,-1)>H AND C<ref(L,-1);

graph0 = close;
graph0style = 128;


graphxspace=5;

graph0barcolor = IIF( CPRbuy, 8, IIF( CPRsell,4, IIF( HRbuy,10, IIF( HRsell,11,
IIF( IRbuy,3, IIF( IRsell,15, IIF( KRbuy,6, IIF( KRsell,7, IIF( OCRbuy,9,
IIF( OCRsell,13, IIF( PPRbuy,16, IIF( PPRsell,12, 1 ) ) ) ) ) ) ) ) ) ) ) ) ;


ch= (close-(ref(close,-1)));
chpct=ch/ref(c,-1)*100;


title =date()+" "+name()+" Open"+writeval(O)+" High"+writeval(H)+"
Low"+writeval(L)+" Close" + writeval(graph0) + " Previous Close " +
writeval((ref(graph0,-1))) + "Change=" + writeval(ch)+"
("+writeval(chpct,format=1.2)+"%)";
 

cellclinic

Well-Known Member
Yes Amit Bro .. Request Needs to be attended by an expert surely as it gives only pop ups without mentioning any name & unlimmited @ a time ...

Experts ... Kindly Look Into It & resolve it as a great help :)
The basic code.Not very attractive.
Needs to be refined by an expert.

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("DONCHAIN1");
// Plots a 20 period Donchian channel

pds=144;
DonchianUpper =HHV(Ref(C,-1),pds);
DonchianLower = LLV(Ref(C,-1),pds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


Plot(DonchianUpper,"DU",colorGreen,styleLine);
Plot(DonchianMiddle,"DM",colorViolet,styleNoDraw);
Plot(DonchianLower,"DL",colorRed,styleLine);

_SECTION_BEGIN("DONCHAIN2");
// Plots a 20 period Donchian channel

pds1=720;
DonchianUpper1 =HHV(Ref(C,-1),pds1);
DonchianLower1 = LLV(Ref(C,-1),pds1);
DonchianMiddle1 = (DonchianUpper1+DonchianLower1)/2;


Plot(DonchianUpper1,"DU1",colorDarkRed,styleThick);
Plot(DonchianMiddle1,"DM1",colorWhite,styleNoDraw);
Plot(DonchianLower1,"DL1",colorRed,styleThick);
Buy=Cross(C,DonchianUpper);
Buy1=Cross(C,DonchianUpper1);
Sell=Cross(DonchianLower,C);
Sell1=Cross(DonchianLower1,C);
Buy=Buy OR Buy1;
Sell=Sell OR Sell1;
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
 PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
PopupWindow("Buy : " + FullName(),"BUY", 5, 640*mtRandom(), 480*mtRandom());
PopupWindow("Sell : " + FullName(),"SELL", 5, 640*mtRandom(), 480*mtRandom());
 
Can Any one help this afl for writing polt text in tittle like CPRbuy, CPR sell and another bar reversal setup.

/*Color Coded Short Term Reversal Signals
by Larry Lovrencic

Some of the colors may need to change depending on your choice of background
color.
This has been coded for a white background*/

/*Closing Price Reversals*/
CPRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<ref(H,-1) AND L<ref(L,-1) AND
C>ref(C,-1);
CPRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H>ref(H,-1) AND L>ref(L,-1) AND
C<ref(C,-1);

/*Hook Reversals*/
HRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<ref(H,-1) AND L>ref(L,-1);
HRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H<ref(H,-1) AND L>ref(L,-1);

/*Island Reversals*/
IRbuy=ref(L,-2)>ref(H,-1) AND L>ref(H,-1);
IRsell=ref(H,-2)<ref(L,-1) AND H<ref(L,-1);

/*Key Reversals*/
KRbuy=O<ref(C,-1) AND L<ref(L,-1) AND C>ref(H,-1);
KRsell=O>ref(C,-1) AND H>ref(H,-1) AND C<ref(L,-1);

/*Open Close Reversals*/
OCRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<ref(H,-1) AND L<ref(L,-1) AND
C<ref(C,-1);
OCRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H>ref(H,-1) AND L>ref(L,-1) AND
C>ref(C,-1);

/*Pivot Point Reversals*/
PPRbuy=ref(L,-1)<ref(L,-2) AND ref(L,-1)<L AND C>ref(H,-1);
PPRsell=ref(H,-1)>ref(H,-2) AND ref(H,-1)>H AND C<ref(L,-1);

graph0 = close;
graph0style = 128;


graphxspace=5;

graph0barcolor = IIF( CPRbuy, 8, IIF( CPRsell,4, IIF( HRbuy,10, IIF( HRsell,11,
IIF( IRbuy,3, IIF( IRsell,15, IIF( KRbuy,6, IIF( KRsell,7, IIF( OCRbuy,9,
IIF( OCRsell,13, IIF( PPRbuy,16, IIF( PPRsell,12, 1 ) ) ) ) ) ) ) ) ) ) ) ) ;


ch= (close-(ref(close,-1)));
chpct=ch/ref(c,-1)*100;


title =date()+" "+name()+" Open"+writeval(O)+" High"+writeval(H)+"
Low"+writeval(L)+" Close" + writeval(graph0) + " Previous Close " +
writeval((ref(graph0,-1))) + "Change=" + writeval(ch)+"
("+writeval(chpct,format=1.2)+"%)";
Delete all the lines marked red from your code and add following in its place. Lines marked blue can be repeated for HRBuy/Sell, OCR Buy/Sell ...

Code:
Plot(Close, "", IIF( CPRbuy, 8, IIF( CPRsell,4,  IIF( HRbuy,10, IIF( HRsell,11,
IIF( IRbuy,3,  IIF( IRsell,15, IIF( KRbuy,6,  IIF( KRsell,7,  IIF( OCRbuy,9, 
IIF( OCRsell,13,  IIF( PPRbuy,16,  IIF( PPRsell,12, 1 ) ) ) ) ) ) ) ) ) ) ) ), styleCandle);

[COLOR="RoyalBlue"]Plot(CPRbuy, "CPR Buy", colorBlue, styleOwnScale | styleLine | styleNoLabel); 
Plot(CPRSell, "CPR Sell", colorRed, styleOwnScale | styleLine | styleNoLabel); 
[/COLOR]
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
 

chintan786

Well-Known Member
Hi All,

I want to plot OI in intraday chart in line Format. But condition is:

1. colour of line should changes to Red if value is less then previous one and

2. Changes to Green if value is greater then previous one.

Regards,
Chintan
Dear Amit and Happyji,

Can u plz look into my request if u have some spare time.

Regards,
Chintan
 

chintan786

Well-Known Member
http://www.wis estoc ktrader.com/indicators/3127-open-interest-oi
(please remove spaces)
Thanks Amit,

But it is showing in Histogram format and I want single horizantal line:

here is the code:

_SECTION_BEGIN("oi");
//Plot( OI, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ), 2 );
_SECTION_END();
//written by Thomas Zmuck
//Date: 15-07-02
//[email protected]

pds = 10;
V1 = OI/MA(OI,10); V2 = OI/MA(OI,20);
V3 = OI/MA(OI,50);
x=100*OI/MA(OI,pds);
barcolor =
IIf( x>Ref(x,-1),5,6);
/* Colourized price bars drawn here */
Plot(100*OI/MA(OI,pds)," oi/ma(10)",barcolor,2+4);

Plot(100," AVG(10)",1,1);

unsure = V1<1 AND V2<1 AND V3<1;
sure = V1>1 AND V2>1 AND V3>1;

Filter = unsure;
AddColumn(100*V/MA(V,10),"V/ma(V,10)",1.0);
AddColumn(100*V/MA(V,20),"V/ma(V,20)",1.0);
AddColumn(100*V/MA(V,50),"V/ma(V,50)",1.0);
AddColumn(ROC(C,1),"%today");
 

copypasteaee

Humbled by Markets
................................
 
Last edited:
hello All,

thanks for running this thread for helping traders without programming knowledge.
I am looking for a exploration code which shows daily RSI high -low for all scrips in watchlist.

EQ:

Scrip RSI(h) RSI(L)
 

Similar threads