Need Help with this AFL

#31
hi ahutosh

thanks for your help. it works fine for me now.

Mean while i developed another system with the following conds.

Buy when

RSI( 14 ) < 50, MACD( 12, 26 ) > 0 and
MA( Close , 4 ) > MA( Close , 17 ) and
MA( Close , 17 ) > EMA( Close , 34 ) and
EMA( Close , 34 ) > MA( Close , 50 ); and vice versa for sell.

i developed the afl and am attaching the same with the chart so far i get.
i have taken only buy1 and sell3 to print as i don't know how should i do this.

i need a buy only when all the ma's cond get satisfied or sell only when all fails. kindly see to this and help me ashutosh. hope am not bugging u much.

ramash
Hi ramash,
try this for your buy and sell conditions:

Code:
RSI14 = RSI(14);
MACD1226 = MACD(12,26);
MA4 = MA(C, 4);
MA17 = MA(C, 17);
EMA34 = EMA(C, 34);
MA50 = MA(C, 50);
Buy = IIf(RSI14 < 50,IIf(MACD1226>0,IIf(MA4 > MA17,IIf(MA17>EMA34,IIf(EMA34>MA50,1,0),0),0), 0),0);
Sell = IIf(RSI14 > 50,IIf(MACD1226<0,IIf(MA4 < MA17,IIf(MA17<EMA34,IIf(EMA34<MA50,1,0),0),0), 0),0);
and change other codes accordingly, i.e. remove all the buy1s, 2s, etc.
 
#32
I need some advice for this afl, anyone willing to give some advice on how to do it?

1) Condition to buy when the MACD Line cross over the signal line. And Sell after the signal line cross the MACD Line.

2) Next is it possible to buy on the opening of the next bar immediately after the cross over(MACD line cross signal line) and sell on the the opening of the next bar when reach the next crossover(Singal line cross the MACD Line).

Formula of MACD as following
_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 19, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorBlack ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
_SECTION_END();


Many thanks
 
#34
hi ashutosh,

I checked the afl's with my requirements. I find some places misses the signals when i have rsi and macd also in the same condn. Also if i changed the rsi and macd conditions no signals come

keeping these things in mind have made slight changes with only the ma's. But can u tell me what that condn on a whole do as am bit confused with 1 and 0 which u have added

once again thank you for your efforts.

ramash75
 

Similar threads