Simple Coding Help - No Promise.

Seniors,

Below is the AFL for Stochastic cross with buy + sell signals, including scanning option.

HTML:
_SECTION_BEGIN("Cross Stochastic");

uptrend= IIf( StochK(17,9) > StochD(17,9,3), 1, 0 );
downtrend=IIf( StochK(17,9)<StochD(17,9,3), 1, 0 );
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));

 Plot( StochD(17,9,3), _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

Plot( StochK(17,9), _DEFAULT_NAME(), colorBlue , ParamStyle("Style") );


Buy =  Ref(crossBuy,-2)  AND  Ref(StochD(9,5,3),-2) <20 AND Ref(uptrend,-1) AND uptrend ;
Sell = crossSell  AND StochD(9,5,3) > 50 ;

Short=Sell;
Cover=Buy;

PlotShapes( IIf(Buy, shapeUpArrow,0) , colorGreen ,0,StochD(17,9,3),-10);
PlotShapes( IIf(Sell, shapeDownArrow,0) , colorRed ,0, StochD(17,9,3),-10);


_SECTION_END();
I need some modifications in this as written below:-
1. Include 3 lines @ 90 level, 50 level and 10 level.
2. Buy and sell signals should be based on stochastic cross below 10 level and above 90 level only.
3. Please include exploration based on buy and sell signals as written in point 2.

Thanks,
Ashish
 
Seniors,

Below is the AFL for Stochastic cross with buy + sell signals, including scanning option.

HTML:
_SECTION_BEGIN("Cross Stochastic");

uptrend= IIf( StochK(17,9) > StochD(17,9,3), 1, 0 );
downtrend=IIf( StochK(17,9)<StochD(17,9,3), 1, 0 );
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));

 Plot( StochD(17,9,3), _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

Plot( StochK(17,9), _DEFAULT_NAME(), colorBlue , ParamStyle("Style") );


Buy =  Ref(crossBuy,-2)  AND  Ref(StochD(9,5,3),-2) <20 AND Ref(uptrend,-1) AND uptrend ;
Sell = crossSell  AND StochD(9,5,3) > 50 ;

Short=Sell;
Cover=Buy;

PlotShapes( IIf(Buy, shapeUpArrow,0) , colorGreen ,0,StochD(17,9,3),-10);
PlotShapes( IIf(Sell, shapeDownArrow,0) , colorRed ,0, StochD(17,9,3),-10);


_SECTION_END();
I need some modifications in this as written below:-
1. Include 3 lines @ 90 level, 50 level and 10 level.
2. Buy and sell signals should be based on stochastic cross below 10 level and above 90 level only.
3. Please include exploration based on buy and sell signals as written in point 2.

Thanks,
Ashish

SMALL EFFORT- if helps:

Code:
_SECTION_BEGIN("Cross Stochastic");

Graph0=50;
Graph1=90;
Graph2=10;

Plot(Graph0,"",2,1);
Plot(Graph1,"",4,1);
Plot(Graph2,"",8,1);
uptrend= IIf( StochK(17,9) > StochD(17,9,3), 1, 0 );
downtrend=IIf( StochK(17,9)<StochD(17,9,3), 1, 0 );
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));

 Plot( StochD(17,9,3), _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

Plot( StochK(17,9), _DEFAULT_NAME(), colorBlue , ParamStyle("Style") );


Buy =  Ref(crossBuy,-2)  AND  Ref(StochD(9,5,3),-2) <20 AND Ref(uptrend,-1) AND uptrend ;
Sell = crossSell  AND StochD(9,5,3) > 50 ;

Buy2=Cross(StochK(17,9),Graph2);
Sell2=Cross(StochD(17,9,3),Graph1);

//Buy2=Cross(StochK(17,9),Graph2) AND StochK(17,9)>10 ;
//Sell2=Cross(StochD(17,9,3),Graph1) AND StochD(17,9,3)<90;

Short=Sell;
Cover=Buy;

PlotShapes( IIf(Buy, shapeUpArrow,0) , colorGreen ,0,StochD(17,9,3),-10);
PlotShapes( IIf(Sell, shapeDownArrow,0) , colorRed ,0, StochD(17,9,3),-10);

PlotShapes( shapeSmallUpTriangle* Buy2 , colorBlue);
PlotShapes( shapeSmallDownTriangle* Sell2 ,colorRed);
Filter=1;
SetSortColumns(-3);
AddColumn(IIf(Buy2 ,Ref(c,0) ,Null),"Buy stoch ",6.2,2,29);  
AddColumn(IIf(Sell2 ,-Ref(c,0),Null),"Sell stoch",6.2,2,4);


_SECTION_END();
regards,
manoj
 
Last edited:
SMALL EFFORT- if helps:

Code:
_SECTION_BEGIN("Cross Stochastic");

Graph0=50;
Graph1=90;
Graph2=10;

Plot(Graph0,"",2,1);
Plot(Graph1,"",4,1);
Plot(Graph2,"",8,1);
uptrend= IIf( StochK(17,9) > StochD(17,9,3), 1, 0 );
downtrend=IIf( StochK(17,9)<StochD(17,9,3), 1, 0 );
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));

 Plot( StochD(17,9,3), _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

Plot( StochK(17,9), _DEFAULT_NAME(), colorBlue , ParamStyle("Style") );


Buy =  Ref(crossBuy,-2)  AND  Ref(StochD(9,5,3),-2) <20 AND Ref(uptrend,-1) AND uptrend ;
Sell = crossSell  AND StochD(9,5,3) > 50 ;

Buy2=Cross(StochK(17,9),Graph2);
Sell2=Cross(StochD(17,9,3),Graph1);

Short=Sell;
Cover=Buy;

PlotShapes( IIf(Buy, shapeUpArrow,0) , colorGreen ,0,StochD(17,9,3),-10);
PlotShapes( IIf(Sell, shapeDownArrow,0) , colorRed ,0, StochD(17,9,3),-10);

PlotShapes( shapeSmallUpTriangle* Buy2 , colorBlue);
PlotShapes( shapeSmallDownTriangle* Sell2 ,colorRed);
Filter=1;
SetSortColumns(-3);
AddColumn(IIf(Buy2 ,Ref(c,0) ,Null),"Buy stoch ",6.2,2,29);  
AddColumn(IIf(Sell2 ,-Ref(c,0),Null),"Sell stoch",6.2,2,4);


_SECTION_END();
regards,
manoj
Thanks Manoj for your efforts :)
Some issues are in this afl:-
1. Buy signal should only be when Stoch. crossover is below 10 level and not inbetween.
2. Sell signal should only be when Stoch. crossover is above 90 level and not inbetween.
3. Scan option should be based on above two conditions.

basically, I want to eliminate signals inbetween 90 and 10 levels.

Thanks,
Ashish.
 
try modified code : conditions (commented)

comment existing buy sell conditions.
ie

//Buy2=Cross(StochK(17,9),Graph2) ;
//Sell2=Cross(StochD(17,9,3),Graph1);
Buy2=Cross(StochK(17,9),Graph2) and StochK(17,9)>10 ;
Sell2=Cross(StochD(17,9,3),Graph1) and StochD(17,9,3)<90;

hope this help.

~ manoj
Thanks Manoj,

Sorry, don't know where to put these new lines in AFL:(

Appreciate if you could post updated afl including new condition:)
 

Nehal_s143

Well-Known Member
Thanks Manoj,

Sorry, don't know where to put these new lines in AFL:(

Appreciate if you could post updated afl including new condition:)
Code:
_SECTION_BEGIN("Cross Stochastic");

Graph0=50;
Graph1=90;
Graph2=10;

Plot(Graph0,"",2,1);
Plot(Graph1,"",4,1);
Plot(Graph2,"",8,1);
uptrend= IIf( StochK(17,9) > StochD(17,9,3), 1, 0 );
downtrend=IIf( StochK(17,9)<StochD(17,9,3), 1, 0 );
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));

 Plot( StochD(17,9,3), _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

Plot( StochK(17,9), _DEFAULT_NAME(), colorBlue , ParamStyle("Style") );


Buy =  Ref(crossBuy,-2)  AND  Ref(StochD(9,5,3),-2) <20 AND Ref(uptrend,-1) AND uptrend ;
Sell = crossSell  AND StochD(9,5,3) > 50 ;

//Buy2=Cross(StochK(17,9),Graph2) ;
//Sell2=Cross(StochD(17,9,3),Graph1);
Buy2=Cross(StochK(17,9),Graph2) and StochK(17,9)>10 ;
Sell2=Cross(StochD(17,9,3),Graph1) and StochD(17,9,3)<90;

Short=Sell;
Cover=Buy;

PlotShapes( IIf(Buy, shapeUpArrow,0) , colorGreen ,0,StochD(17,9,3),-10);
PlotShapes( IIf(Sell, shapeDownArrow,0) , colorRed ,0, StochD(17,9,3),-10);

PlotShapes( shapeSmallUpTriangle* Buy2 , colorBlue);
PlotShapes( shapeSmallDownTriangle* Sell2 ,colorRed);
Filter=1;
SetSortColumns(-3);
AddColumn(IIf(Buy2 ,Ref(c,0) ,Null),"Buy stoch ",6.2,2,29);  
AddColumn(IIf(Sell2 ,-Ref(c,0),Null),"Sell stoch",6.2,2,4);


_SECTION_END();
 
Code:
_SECTION_BEGIN("Cross Stochastic");

Graph0=50;
Graph1=90;
Graph2=10;

Plot(Graph0,"",2,1);
Plot(Graph1,"",4,1);
Plot(Graph2,"",8,1);
uptrend= IIf( StochK(17,9) > StochD(17,9,3), 1, 0 );
downtrend=IIf( StochK(17,9)<StochD(17,9,3), 1, 0 );
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));

 Plot( StochD(17,9,3), _DEFAULT_NAME(), colorRed , ParamStyle("Style") );

Plot( StochK(17,9), _DEFAULT_NAME(), colorBlue , ParamStyle("Style") );


Buy =  Ref(crossBuy,-2)  AND  Ref(StochD(9,5,3),-2) <20 AND Ref(uptrend,-1) AND uptrend ;
Sell = crossSell  AND StochD(9,5,3) > 50 ;

//Buy2=Cross(StochK(17,9),Graph2) ;
//Sell2=Cross(StochD(17,9,3),Graph1);
Buy2=Cross(StochK(17,9),Graph2) and StochK(17,9)>10 ;
Sell2=Cross(StochD(17,9,3),Graph1) and StochD(17,9,3)<90;

Short=Sell;
Cover=Buy;

PlotShapes( IIf(Buy, shapeUpArrow,0) , colorGreen ,0,StochD(17,9,3),-10);
PlotShapes( IIf(Sell, shapeDownArrow,0) , colorRed ,0, StochD(17,9,3),-10);

PlotShapes( shapeSmallUpTriangle* Buy2 , colorBlue);
PlotShapes( shapeSmallDownTriangle* Sell2 ,colorRed);
Filter=1;
SetSortColumns(-3);
AddColumn(IIf(Buy2 ,Ref(c,0) ,Null),"Buy stoch ",6.2,2,29);  
AddColumn(IIf(Sell2 ,-Ref(c,0),Null),"Sell stoch",6.2,2,4);


_SECTION_END();
Thanks a lot Nihal :thumb:
It is not showing sell signal. Example- check Indusind bank future chart, there is a sell signal generated as shown in chart attached.



FYI, I am using hourly chart. There is also 1 more sell signal on 19th May which is not coming in exploration results.

Thanks,
Ashish..
 
Last edited:

extremist

Well-Known Member
Thanks a lot Nihal :thumb:
It is not showing sell signal. Example- check Indusind bank future chart, there is a sell signal generated as shown in chart attached.



FYI, I am using hourly chart. There is also 1 more sell signal on 19th May which is not coming in exploration results.

Thanks,
Ashish..

@ashish2010

bro i'm sorry u might fill bad due to hard words i'm going to use now.

U requested a code.
People took hard work to give you the code as per ur need.

and now u r coming again with show of ur laziness?

at least u should have zoomed in zoomed out the graph. tried to scroll it a bit and tried to see whether the arrow really present or not.
u can not see arrow coz the title line eclipsed it.
it was very easy bro.
and if u r going to say tht u don't understand ami and it's coding...
then please don't use it ever if u can not simply scroll the chart and chk it.
and if u r going to say tht u don't understand ami and it's coding...
then please don't use it ever if u can not simply scroll the chart and chk it.

sorry bro for my words but now a days people have very less zest to learn something.
the want everything served ready in platter.
they don't even stop here they want it to be fed to them.

Come on trader brothers .... take little efforts.
i'm no GURU but trying hard to learn things.
 
Last edited:
@ashish2010

bro i'm sorry u might fill bad due to hard words i'm going to use now.

U requested a code.
People took hard work to give you the code as per ur need.

and now u r coming again with show of ur laziness?

at least u should have zoomed in zoomed out the graph. tried to scroll it a bit and tried to see whether the arrow really present or not.
u can not see arrow coz the title line eclipsed it.
it was very easy bro.
and if u r going to say tht u don't understand ami and it's coding...
then please don't use it ever if u can not simply scroll the chart and chk it.

sorry bro for my words but now a days people have very less zest to learn something.
the want everything served ready in platter.
they don't even stop here they want it to be fed to them.

Come on trader brothers .... take little efforts.
i'm no GURU but trying hard to learn things.
Extremist,

I got your point what you are saying. No issues at all about your hard words;).
You are right that most people need everything served to them:mad:

I can see the sell signal with zoom in and out, that's not an issue.
Issue is exploration doesn't highlight this sell signal in it. It is showing only buy signals (blue triangle in red circles, refer attached chart). Also attached is the exploration chart snapshot which shows only buy signals (I have checked it and it shows no sell signal).

Hope this clears misunderstanding..




 

Similar threads