Simple Coding Help - No Promise.

Romeo1998

Well-Known Member
Dear friend Raj Jain,
I am not able to understand clearly :pompus:
please correct me if i m wrong :happy:
1) u want to scan all stocks whose price is above 100
2) then u want to take the high n low only from 10:15 am to 1:30 pm of those stocks
3) then if from 1:30 pm to 3:30 pm the high or low of 10:15 am to 1:30 pm of the same day is broken, then a sell or buy signal must be triggered
these r the conditions u want to be fulfilled ?
 
no Romeo sir ...
scan should be start if 10.15am candle close above previous candles high and closing candle wicks should not be big and scan will continue till 2.00pm.
same as for sell condition if 10.15am candle close below previous candles low and same as above.

and most important once a stock is matched on above condition then that stock should not repeat if it again closed above previous candles high.

all this scan should be done only till 2.00 pm candle closing... nothing should be scan after it.
i have attached a screenshot of it pls see it.
 

Attachments

Romeo1998

Well-Known Member
Dear friend Raj Jain,
here is the code for the required buy and sell conditions :happy:
1) it will check if price is higher than 100
2) will take the high n low from 9:15 am to 10:15 am
3) will buy when low from 9:15 to 10:15 is broken by close of 15 mins candle
4) will sell when high from 9:15 to 10:15 is broken by close of 15 mins candle
5) and once a buy signal is generated , it wont generate consecutive buy signals; it will generate another buy signal only if a sell signal has been generated earlier and vice versa ( means it will only keep 1 open position, once the open position is closed, only then a new position will be opened ) :happy:
u can use this in analysis window for scan, explore n backtest too :happy:
let me know if everything is working as it should :D ( bcoz i make many silly mistakes too ) :D
Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
pricecond = C>100;
tn = TimeNum();
StartTime = 91500;
Endtime = 101500;
StartBar = tn == StartTime;
EndBar = tn == Endtime;
myH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
myL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );
c15= TimeFrameGetPrice("C",in15Minute,0,expandLast);
Buy = Cover = tn >endbar AND tn<=330000  AND pricecond AND Cross(c15,myh);
Sell = Short = tn>endbar AND tn<=330000  AND pricecond AND Cross(myl,c15);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorWhite,0,L,-12);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorWhite,0,H,-12);
Filter = Buy OR Sell;
AddColumn(IIf(Buy,C,Null),"Buy",1.2,colorgreen);
AddColumn(IIf(Sell,C,Null),"Sell",1.2,colorred);
_SECTION_END();
:happy:
 
Last edited:
Dear friend Raj Jain,
here is the code for the required buy and sell conditions :happy:
1) it will check if price is higher than 100
2) will take the high n low from 9:15 am to 10:15 am
3) will buy when low from 9:15 to 10:15 is broken by close of 15 mins candle
4) will sell when high from 9:15 to 10:15 is broken by close of 15 mins candle
5) and once a buy signal is generated , it wont generate consecutive buy signals; it will generate another buy signal only if a sell signal has been generated earlier and vice versa ( means it will only keep 1 open position, once the open position is closed, only then a new position will be opened ) :happy:
u can use this in analysis window for scan, explore n backtest too :happy:
let me know if everything is working as it should :D ( bcoz i make many silly mistakes too ) :D
Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
pricecond = C>100;
tn = TimeNum();
StartTime = 91500;
Endtime = 101500;
StartBar = tn == StartTime;
EndBar = tn == Endtime;
myH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
myL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );
c15= TimeFrameGetPrice("C",in15Minute,0,expandLast);
Buy = Cover = tn >endbar AND tn<=330000  AND pricecond AND Cross(c15,myh);
Sell = Short = tn>endbar AND tn<=330000  AND pricecond AND Cross(myl,c15);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorWhite,0,L,-12);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorWhite,0,H,-12);
Filter = Buy OR Sell;
AddColumn(IIf(Buy,C,Null),"Buy",1.2,colorgreen);
AddColumn(IIf(Sell,C,Null),"Sell",1.2,colorred);
_SECTION_END();
:happy:
Thank u sir...are u also a nse trader?
I will test this afl tomorrow morning.
Sir have u also coded in that closed candle wicks not so big?

Sent from my CHM-U01 using Tapatalk
 

Romeo1998

Well-Known Member
Dear friend Raj Jain,
the following code will also check the length of wick with respect to the candle's body :happy:
condition for length of wick is -- it must be less than 50% of candle's body :happy:
here is the modified code :happy:
Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
pricecond = C>100;
tn = TimeNum();
StartTime = 91500;
Endtime = 101500;
StartBar = tn == StartTime;
EndBar = tn == Endtime;
myH = ValueWhen( EndBar, HighestSince( StartBar, High ) );
myL = ValueWhen( EndBar, LowestSince( StartBar, Low ) );
c15= TimeFrameGetPrice("C",in15Minute,0,expandLast);
l15= TimeFrameGetPrice("L",in15Minute,0,expandLast);
h15= TimeFrameGetPrice("H",in15Minute,0,expandLast);
o15= TimeFrameGetPrice("O",in15Minute,0,expandLast);
Realbody =abs(O15-C15);
Lowershadow = abs(Min(O15,C15) - L15);
Uppershadow =abs( H15 - Max(O15,C15));
ll = ((abs(Min(O15,C15) - L15))/realbody)*100;
hh = ((abs( H15 - Max(O15,C15)))/realbody)*100;
condl = L==ValueWhen(ll<50,L);
condh = H==ValueWhen(hh<50,H);
cond3 = condl AND condh;
Buy = Cover = tn >endbar AND tn<=330000  AND pricecond AND cond3 AND Cross(c15,myh);
Sell = Short = tn>endbar AND tn<=330000  AND pricecond AND cond3 AND Cross(myl,c15);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorWhite,0,L,-12);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorWhite,0,H,-12);
Filter = Buy OR Sell;
AddColumn(IIf(Buy,C,Null),"Buy",1.2,colorgreen);
AddColumn(IIf(Sell,C,Null),"Sell",1.2,colorred);
_SECTION_END();
:happy:
 

Romeo1998

Well-Known Member
Dear friend Loveenajyothi,
i m not VijKrish gaaru :happy:
i searched in google abt Kase Peak Oscillator and found it here :pompus:
http://www.wisestocktrader.com/indicators/4317-kase-peak-osc-v2-batu
i hope this helps :happy:
Code:
_SECTION_BEGIN("Kase Peak Osc Orginal V2.batu");
Per1=Param("Max Length",55,2,200,1);
Per2=Param("Min Length",13,2,200,1);
RWH=RWIHi(Per2,Per1);
RWL=RWILo(Per2,Per1);
Pk=WMA((RWH-RWL),3);
MN=MA(Pk,Per1);
SD=StDev(Pk,Per1);
Val1=Max(MN+(2*SD),2.2*SD);
Val2=Min(MN-(2*SD),-2.2*SD);
Val3=Max(MN+(2*SD),3*SD);
Val4=Min(MN-(2*SD),-3*SD);
LN1=IIf(PK>=0,Val1,Val2);
LN2=IIf(PK>=0,Val3,Val4);
Red=IIf(Ref(Pk,-1)>Pk,Pk,0);
Green=IIf(Pk>Ref(Pk,-1),Pk,0);

WriteIf( Val2>=Pk, "Buraya yazabilirsin", "Buraya yaziliyor" );

Buy= IIf(Pk<Val2,Val2>=Pk-0.01,Val2>=Pk);
Sell= IIf(Pk>Val1,Pk+0.01>=Val1,Pk>=Val1);

for( i = 0; i < BarCount; i++ )
 {
if( Buy[i] ) PlotText( "Pk<" + Val2[ i ], i, Pk[ i ]-2, colorGreen,colorWhite);
if( Sell[i] ) PlotText( "Pk>" + Val1[ i ], i, Pk[ i ]+2, colorRed,colorWhite);
  }

PlotShapes( Buy *18,IIf( Buy, colorGreen, colorRed ),0,0);
PlotShapes(Sell * 17, IIf( Buy, colorGreen, colorRed ),0,0);

Buy= IIf(Pk<Val4,Val4>=Pk-0.01,Val4>=Pk);
Sell= IIf(Pk>Val3,Pk+0.01>=Val3,Pk>=Val3);
Plot(Red,"Red min "+per2+"-max "+per1,IIf(Buy,11,colorOrange),styleHistogram|styleThick,Null,Null,0,1);
Plot(Green,"Green min"+per2+"-max "+per1,IIf(Sell,11,colorGreen),styleHistogram|styleThick,Null,Null,0,1);
Plot(LN1,"StDev Loc",colorViolet,styleLine);
Plot(ln2,"StDev GL",colorTurquoise,styleLine);
_SECTION_END();
thank u for helping me earlier :happy:
:happy:
 
Last edited:

Similar threads