Simple Coding Help - No Promise.

Logic of Code is borrowed from Metastock expert so I expected it to work correctly.But somehow it misses divergences even within 9 bars.You may use it to check.Pl. correct it.

code seems ok subject to
1. It is not comparing corresponding close...that is the HHV close maybe on a diff bar from HHV of RSI. But I don't think this should be a big issue.

2. more importantly, is the fact that it will detect only RSI divergences that happen within 9 bars
 

Giraffe

Well-Known Member
How do I add a filter for percentage change in this exploration for INTRADAY? (Percentage change from previous day's close). Basically I want to see only stocks that have gained or lost more than 2% compared to previous day's close and that meet the criteria of moving average crossover.

Buy = Cross( MA(Close, 15 ) , MA(Close, 75 ));

Sell = Cross( MA(Close, 75 ) , MA(Close, 15 ));

Filter = Buy or Sell;


Please someone guide me regarding this. Is there any way to fetch previous day's closing value in this exploration afl. And yes, everything is INTRADAY.
 

pratapvb

Well-Known Member
Logic of Code is borrowed from Metastock expert so I expected it to work correctly.But somehow it misses divergences even within 9 bars.You may use it to check.Pl. correct it.
Hmmm it is including the current bar in hhv llv calc. Need to get hhv upto prev bar to compare. Will check later
 
How do I add a filter for percentage change in this exploration for INTRADAY? (Percentage change from previous day's close). Basically I want to see only stocks that have gained or lost more than 2% compared to previous day's close and that meet the criteria of moving average crossover.

Please someone guide me regarding this. Is there any way to fetch previous day's closing value in this exploration afl. And yes, everything is INTRADAY.

Code:
UP = H > 1.02 * TimeFrameGetPrice("C",inDaily,-1);
DN = L < 0.98 * TimeFrameGetPrice("C",inDaily,-1);
Filter = UP or DN;


:) Happy
 

pratapvb

Well-Known Member
Logic of Code is borrowed from Metastock expert so I expected it to work correctly.But somehow it misses divergences even within 9 bars.You may use it to check.Pl. correct it.
Hmmm it is including the current bar in hhv llv calc. Need to get hhv upto prev bar to compare. Will check later
check this. just corrected to compare current with HHV/LLV upto prev bar. not gone deeper into the logic.

Also have put period and lookback period as two variables above. They can be made Param if required

have ploted a ribbon on the chart showing rbn and rbp bars

p = 9 ;
Lookback = 9 ;

RBP = ( (RSI(p) >= Ref(HHV(RSI(p), Lookback),-1)) AND
(Close < Ref(HHV(Close, Lookback),-1))
) OR
( (Close <= Ref(LLV(Close, Lookback),-1)) AND
( RSI(p) > Ref(LLV( RSI(p), Lookback),-1))
);
//RSI -ve

RBN = ( ( RSI(p) <= Ref(LLV(RSI(p), Lookback),-1))
AND (Close > Ref(LLV(Close, Lookback),-1))
) OR
( ( Close >= Ref(HHV( Close, Lookback),-1)) AND
( RSI(p) < Ref(HHV( RSI( p ), Lookback), -1))
);

Plot(2, "", IIf(rbp, colorRed, IIf(rbn, colorBlue, colorLavender)), styleArea|styleOwnScale, 0, 100) ;
 

TraderRavi

low risk profile

pratapvb

Well-Known Member
Hi happy, I need an AFL for SH's market correction strategy in which time frame can be changed as parameter(basically I need 5, 15, 30, 60 min and daily, total 5 TF)

condition is to count the candles when 3 EMA, 15 EMA, 34 EMA, 100 EMA last touched the price.

thread link for SH's MArket Correction Prediction Strategy..........

http://www.traderji.com/technical-analysis/36825-shs-market-correction-prediction-strategy.html
how do you want the values displayed? In some kind of panel to the right of chart? or any other ideas?
 

ocil

Well-Known Member
Hi Friends I need help. Is there any way in Amibroker AFL that if WRB come (wide range bar) no signal will be generated ? Thanks for your help...
 
Hi Friends I need help. Is there any way in Amibroker AFL that if WRB come (wide range bar) no signal will be generated ? Thanks for your help...
Define the WRB as per your requirement.

for e.g.

WRB = (H - L)/C > 0.01;

then add this condition to the Buy and Short statements

AND (NOT(WRB))
 

Similar threads