Help need to generate buy n sell signal in this afl code

#1
Hi all gr8 gurus,
here is a afl code of an oscillator.
it wud b of gr8 help if someone can provide me afl code for buy n sell signals in the same as per my requirement.
buy signal is whn the diff between the DTOscSk and DTOscSD increases relative to prev day diff.
Sell signal is whn the diff between the DTOscSk and DTOscSD decreases relative to prev day diff.
I hve attached a sample data sheet also. pls hve a look @ it.

Code:-

_SECTION_BEGIN("New formula 5 3");
PeriodRSI= Param("PeriodRSI", 13, 1, 250, 1);
PeriodStoch=Param("PeriodStoch", 8, 1, 250, 1);
MAType=Param("MAType", 1, 1, 2, 1);
PeriodSK=Param("PeriodSK", 5, 1, 250, 1);
PeriodSD=Param("PeriodSD", 3, 1, 250, 1);
Upper=Param("Upper", 70, 50, 100, 1);
Lower=Param("Lower", 30, 0, 50, 1);


StoRSI= 100*(( RSI( PeriodRSI) - LLV( RSI( PeriodRSI ) , PeriodStoch ) ) / ( (
HHV( RSI( PeriodRSI) , PeriodStoch ) ) - LLV(RSI( PeriodRSI ), PeriodStoch ) )
);

if(MAType==1)
{
SK=MA(StoRSI,PeriodSK);
SD=MA(SK,PeriodSD);
}

if(MAType==2)
{
SK=EMA(StoRSI,PeriodSK);
SD=EMA(SK,PeriodSD);
}

Plot(SK,"DTOscSK",ParamColor( "ColorSK", colorBlue ),styleLine);
Plot(SD,"DTOscSD",ParamColor( "ColorSD", colorYellow ),styleDashed);
Plot(0,"ZeroLine",ParamColor( "ColorZero", colorPink ),styleLine);
Plot(Upper,"Upper",ParamColor( "ColorUpper", colorRed ),styleLine);
Plot(Lower,"Lower",ParamColor( "ColorLower", colorGreen ),styleLine);
_SECTION_END();

Thnxs in advance n in hope of a reply soon.
 
Last edited:
#2
I have understood the requirement correctly, then the following code should generate the signals. Add it to the end of the AFL.
Thnxs for ur effort....but its not generating signals .......it wud b gr8 if the signals r given by green up arrow for buy n red down arrow for sell.
 
#3
I tested it and it generated the trades as expected.

Did you run it in the back-tester ?

Menu -> Analysis -> Automatic Analysis -> (Pick the AFL, symbol etc) -> press Back Test.
Thnxs for ur kind reply......in bcktest its showing only buy calls.....n whn scanned it shows trade everyday...........cud u correct it??

n it wud b gr8 if u cud get signals shown by arrows.
 

Similar threads