i need to make some minor adjustments in my small afl . plz dont scare as it simple code carrying only 15-20 lines . following is the code and the pointwise requirements:-
/* myf
**
**
**
*/
PeriodRSI= Param("PeriodRSI", 13, 1, 250, 1);
PeriodStoch=Param("PeriodStoch", 8, 1, 250, 1);
MAType=Param("MAType", 1, 1, 2, 1);
PeriodSK=Param("PeriodSK", 3, 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);
}
/*
Buy= if Cross(sk, sd)on closing basis, then Buy above High of that candle
Sell=Cross(sd, sk) on candle closing(then exit immediately at closing) OR price equal to one tick below the Low of previous two candles for every ongoing candle
Short= Cross(sd, SK )on closing basis(then Buy below Low of that candle)
Cover= Cross(sk, sd) on candle closing OR price equals to one tick above High of previous two candles,, for every ongoing candle
*/
Plot(C,"\nPrice",IIf(C>O,colorGreen,colorRed),64,0,0,0,0);
Buy1 = Cross(sk,sd);
Short1 = Cross(sd,sk);
//PlotShapes(shapeUpTriangleBuy1,colorGreen,0,L,-42);
//PlotShapes(shapeDownTriangleShort1,colorRed,0,H,-42);
Buy2 = H > ValueWhen(Buy1,H,1) AND BarsSince(Buy1) < BarsSince(Short1) ;
Sell2 = Ref(Short1,-1) OR L < Ref(LLV(L,-2),-1) ;
Short2 = L < ValueWhen(Short1,L,1) AND BarsSince(Buy1) > BarsSince(Short1) ;
Cover2 = Ref(Buy1,-1) OR H > Ref(HHV(H,-2),-1) ;
Buy = ExRem(Buy2,Sell2);
Sell = ExRem(Sell2,Buy2);
Short = ExRem(Short2,Cover2);
Cover = ExRem(Cover2,Short2);
PlotShapes(shapeUpArrowBuy,colorGreen,0,L,-29);
PlotShapes(shapeDownArrowShort,colorRed,0,H,-29);
PlotShapes(shapeCircleSell,colorGreen,0,H,18);
PlotShapes(shapeCircleCover,colorRed,0,L,-18);
Plot(SK,"DTOscSK",ParamColor( "ColorSK", colorBlue ),styleLine|styleOwnScale|styleNoLabel);
Plot(SD,"DTOscSD",ParamColor( "ColorSD", colorYellow ),styleDashed|styleOwnScale|styleNoLabel);
Plot(0,"ZeroLine",ParamColor( "ColorZero", colorWhite ),styleLine|styleOwnScale|styleNoLabel);
Plot(Upper,"Upper",ParamColor( "ColorUpper", colorRed ),styleLine|styleOwnScale);
Plot(Lower,"Lower",ParamColor( "ColorLower", colorGreen ),styleLine|styleOwnScale);
(1) one of the exit conditions not working that is... L<Ref(LLV(L, -2), -1) in sell case and h>ref(hhv(h, -2),-1) in cover case OR might be it disappears when price changes,,,we have to exit as soon as ltp is below the low of previous two in long and vice versa in short.
(2) exit of previous day last signal coming to fresh day....... Only fresh signal to be traded, fresh crossover must to occur first in fresh day....
... Like if we are negative in last candle closing of previous day, then our new candle of 9.15 to 9.30 closes positive signal at 9.30
So we buy above high of 9.15 to 9.30(this is earliest possible case),,, isse jaldi koi signal ni aana chaiye
that is first signal of day must be only a buy or short,,,,not the sell or cover
(3) i am using ref function in first exit condition so the order is initiated at opening of next candle,, make adjustments to locate that to same candle closing(but make sure it remain non repainting and act only if closing price at candle closing validate the condition
(4) the red candles are filled by red colour but green ones are emply plz fill the green colour. :)
seven five zero three eight six eight seven eight seven