Buy sell logic not working, Help required

Hellow, herewith i am keeping the code, i do not know why this is not working. Request for help

buy  = cross(MA(c,10),MA(c,30));  
sell = cross(MA(c,30),MA(c,10));

buy = ( MA(C,10) == MA(c,30) and close > MA(c,30));
Sell = ( MA(C,10) == MA(c,30) and close < MA(c,30));

The first buy is working fine, but second one is not working. Am i missing something? I want to explore where MA10 & MA30 are equal ( or about cross) & price is above/below MA30.
Many thanks in advance

ma10 and ma30 being equal sounds very unrealistic. You should explore how many times this happens. What are the results?

I agree with Peter, it will not happen many time when use MA. But if you use ichimoku system, this condition happen many a times. Its called swardsen ie two componnets of ichimoku ie tenkensen(TL) & kijunsen(KL) move up or down together when trend is very strong & also it stays for long without crossing. In ichimoku terms, let me put the question here so that one can understand & help me.

Buy = cross ( TL,KL);
Sell = cross ( KL,TL);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

The above work fine.
For swardsen, below logic is correct, but AFL code is not working

Buy1 = ( TL == KL and close > KL);
Sell1 = ( TL == KL and close < KL);

Hi, I tried this, it should work but invain, can anybody help me please

Buy1 = IIf(TenkanSen == KijunSen AND Close > KijunSen,1,0  );
Sell1 =  IIf(TenkanSen == KijunSen AND Close < KijunSen,1,0  );


In otherwords,
buy1 = iif(MA(c,10) == MA(c,30) and close > MA(c,30),1,0);
Sell1 = iif(MA(c,10) == MA(c,30) and close < MA(c,30),1,0);

Hi, Now working fine after defining tenjensen & kijunsen once again before buy & sell code. many thanks

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.