AFL writing guide for new user

I am looking for the experts suggestions in these things. please do let me know this.

How to round up the candle high low close price (not while displaying) for calculations only in the afl code writing. (anywhere in traderji math functions info).
the round up may be like this. //....>=29.60 as 30 and <29.60 as 29....//

How to write afl with a series of "if - else structure" and store the final result in the variable.
 

apdd2003

Active Member
Hi DM,
Thanks for this great thread.....

I used your code for plottext and added say() command. so whenever buy signal is generated audio is played.
But problem is whenever i move mouse pointer or scroll chart it starts playing audio of last signal... how to avoid this??

for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy\n@" + C[ i ], i, L[ i ]-dist, colorGreen,colorYellow );
if( Buy ) Say("Buy Alert: Buy now");
if( Sell ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist, colorRed, colorYellow );
if( Sell ) Say("Sell Alert: Sell now");
}
 
This thread gave me a lot to learn AFL writing....I am grateful to Mr DM. I didn't know ABC about AFL coding but now a little bit confident only going through this topics most of the time.
However still I'm eagerly waiting to see the code for the following chart..!
 

Attachments

My 2nd request is, how can be developed a good AFL in the following scenario?

I am trying to write an AFL for positive, negative and hidden divergences, But due to lack of knowledge of coding, m unable to write it clearly. Request seniors to help me writing the AFL.
For finding divergence, I watch Price, Indicators (Fast MACD 5,10,9, Slow MACD 12,26,9, Stochastic 14,3,3 and RSI 14,9) and Trendlines on Price. Breaking TL on Price it will confirm the divergence.
Below is the strategy:
NEGATIVEDIVERGENCE
1-Price is making higher highs while the indicator is making lower highs: Bearish
POSITIVEDIVERGENCE
2-Price is making lower lows while the indicator is making higher lows: Bullish
HIDDEN NEGATIVEDIVERGENCE
3- Price is making lower highs while the indicator is making higher highs: Bearish
HIDDEN POSITIVEDIVERGENCE
4- Price is making higher lows while the indicator is making lower lows: Bullish

I’ve identified Hidden negative Divergence on 04th May 2012. It’s Nifty Futures weekly chart and since that day its DOWN.
I hope it's clear to understand. Please do let me know if you need any more information.

Regards.
 
Hello frnds,
I have the below mentioned AFL for the stop loss. Here , as said, it look backs for certain bars for the stoploss. Whereas i want is, it should start looking for stop loss once the trade is hit (long/short). Please help me to with the same.
Here's the code.

Trailing Stoploss - a% below nth highest high
************************************************** ***/
lookbackPeriod = Param("Lookback period", 10, 2, 30);
stoplossPercentage = Param("Stoploss Percentage", 5, 0.2, 10, 0.2);

Plot(HHV(H,lookbackPeriod) - HHV(H,lookbackPeriod) * (stoplossPercentage / 100), "Bullish SL", ParamColor( "Long", colorGrey40));
Plot(LLV(L,lookbackPeriod) + LLV(L,lookbackPeriod) * (stoplossPercentage / 100), "Bearish SL", ParamColor( "Short", colorGrey40));
 

Similar threads