Seek AFL coding expertise

rpc

Active Member
#12
I do not want to demoralize your adventurous exploration but just changing the default Candle OHLC values to Heiken-Ashi OHLC for the calculation of SuperTrend or MACD won't yield you anything magical.

Seban's SuperTrend is nothing but a Trailing Stop using Wilder's ATR (Average True Range). In order to formulate ATR, actual High Low prices are used; when you change that to Heikin-Ashi High Low, you are further deviating from the reality.

Similarly, MACD measures the difference between two Moving Averages (one fast, other slow) and tries to depict their relationship in terms of their Convergence and Divergence. Now ask yourself, are you in-tune with the real market when you calculate the Moving Average of Heikin-Ashi Close which is a distorted value of the Real actual close of a candle.

When markets trend all indicators show and behave in similar manner because they all are derived from the Price. Thus they all look beautiful on the left side of the chart but its a totally different story on the right of the chart - by no means, it has any power to forecast the future. Let the consolidation of price come, all indicators will whipsaw you out. This is a game of probabilities, so statistics matter not technical indication.

Keep things simple! Mixing up indicators only over-complicate things.

Desi Hindi: Rassi ka ganth kholna hain toh, us ganth to khologey? Ya aur ek ganth lagakey usko kholna chahogey! Anth mein ulajh hi jayoegey na !!!!

In English: If you want to untie a rope, would you untie that knot? Or make another knot to untie the previous knot! At the end, you will ultimately get entangled and confused !!!
Very well said.
 
#13
Is it such a rare skill?
Yes, people with imagination and creativity are rare. 99% of the public just want copy-paste formulas instead of working hard themselves to understand the core concepts. In that perspective, yes remaining 1% is rare! AFL programming is designed in a manner that seeks Human imagination only nothing else.
Are there really no AFL coders out here ?
All it takes is read the AmiBroker user manual couple of times, Google search extensively, practice on your own all the KB articles, visit the AFL Library - play with codes written by others - that's it! may be one day you yourself will become an AFL coder - 6 months to be proficient and a year to be a Pro, in about 4-5 weeks you will notice good results, if you actually dedicate yourself to learning AFL. Let your "prefrontal cortex" lead you. :)
 
#14
Cmon that's not a solution . I have loads of creativity and imagination but frankly no coding acumen. Tried and tested that much earlier in my career and I know that's what it is. So not trying to cover my weaknesses but trying to leverage my strengths. So if I have an AFL coder , I can get my thoughts translated into a good code is what I think. Coding ke maamle mein cortex thoda Khali hai :)

Good conversation though :)
 
#16
Cmon that's not a solution . I have loads of creativity and imagination but frankly no coding acumen. Tried and tested that much earlier in my career and I know that's what it is. So not trying to cover my weaknesses but trying to leverage my strengths. So if I have an AFL coder , I can get my thoughts translated into a good code is what I think. Coding ke maamle mein cortex thoda Khali hai :)

Good conversation though :)
If you are ok with a paid solution then you could call howutrade.in & see what they say.
 
#17
Help me with this AFL need
Vwma
Daily current
Daily previous
Week current
Week previous
Month current
Month previous
Quarter current
Quarter previous
Half yearly current
Half yearly previous
Yearly current
Yearly previous
With names coming along with lines like dp dc
WC WP
MP
MC
Qc qp
Hp
Hv


Yep
Tec
Help ful l for delivery basis
 
#18
Cmon that's not a solution . I have loads of creativity and imagination but frankly no coding acumen. Tried and tested that much earlier in my career and I know that's what it is. So not trying to cover my weaknesses but trying to leverage my strengths. So if I have an AFL coder , I can get my thoughts translated into a good code is what I think. Coding ke maamle mein cortex thoda Khali hai :)

Good conversation though :)
Hope this helps (Do play with the parameters):
SuperTrend on Standard or HA Candles
C-like:
function fSuperTrend( CustHi, CustLo, CustCl, Mult, P, UsingHA )
{
     // Based on AFL KB Article "How to plot a trailing stop in the Price chart" (http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/)
     if( UsingHA )
     {
         CustATR = 0;
         for( i = 1; i <= BarCount - 1; i++ ) CustATR[ i ] = ( Max( CustHi[ i ] - CustLo[ i ], Max( abs( CustHi[ i ] - CustCl[ i - 1 ] ), abs( CustCl[ i - 1 ] - CustLo[ i ] ) ) ) + CustATR[ i - 1 ] * ( P - 1 ) ) / P;
         ModATR = CustATR;
     }
     else ModATR = ATR( P );

     // Alternately you can change "( H + L ) / 2" below to "Close" or anything else that pleases you
     UprBandArr = ( CustHi + CustLo ) / 2 + ( Mult * ModATR );
     LwrBandArr = ( CustHi + CustLo ) / 2 - ( Mult * ModATR );

     UprBand = 0;
     LwrBand = 0;
     ST = 0;
     for( i = 1; i <= BarCount - 1; i++ )
     {
         if( ( UprBandArr[ i ] < UprBand[ i - 1 ] ) || ( CustCl[ i - 1 ] > UprBand[ i - 1 ] ) ) UprBand[ i ] = UprBandArr[ i ];
         else UprBand[ i ] = UprBand[ i - 1 ];

         if( ( LwrBandArr[ i ] > LwrBand[ i - 1 ] ) || ( CustCl[ i - 1 ] < LwrBand[ i - 1 ] ) ) LwrBand[ i ] = LwrBandArr[ i ];
         else LwrBand[ i ] = LwrBand[ i - 1 ];

         // Uptrend
         if( ST[ i - 1 ] == LwrBand[ i - 1 ] )
         {
             if( CustCl[ i ] > LwrBand[ i ] ) ST[ i ] = LwrBand[ i ];
             else if( CustCl[ i ] < LwrBand[ i ] ) ST[ i ] = UprBand[ i ];
             else ST[ i ] = Null;
         }

         // DownTrend
         if( ST[ i - 1 ] == UprBand[ i - 1 ] )
         {
             if( CustCl[ i ] < UprBand[ i ] ) ST[ i ] = UprBand[ i ];
             else if( CustCl[ i ] > UprBand[ i ] ) ST[ i ] = LwrBand[ i ];
             else ST[ i ] = Null;
         }
      }
      return ST;
}

_SECTION_BEGIN( "SuperTrend on Standard or HA Candles" );
     Version( 6.0 );
     SetChartOptions( 0, chartShowDates );

     CandleTyp = ParamToggle( "Choose Candle Type:", "Standard|Heikin-Ashi", 0 );
     if( CandleTyp )
     {
         HaClose = ( O + H + L + C ) / 4;
         HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
         HaHigh = Max( H, Max( HaClose, HaOpen ) );
         HaLow = Min( L, Min( HaClose, HaOpen ) );
         PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", colorDefault, styleCandle | styleNoLabel | styleNoTitle, Null, Null, 0, 0 );
     }
     else Plot( C, "Close", colorDefault, styleCandle | styleNoTitle );

     Factor = Param( "Factor", 3, 1, 10, 1 );
     Per = Param( "Period", 10, 1, 100, 1 );
     StCalc = ParamToggle( "SuperTrend Calculation Type:", "Standard|Heikin-Ashi", 0 );
     if( StCalc )
     {
         HaClose = ( O + H + L + C ) / 4;
         HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
         HaHigh = Max( H, Max( HaClose, HaOpen ) );
         HaLow = Min( L, Min( HaClose, HaOpen ) );
         SuperTrend = fSuperTrend( HaHigh, HaLow, HaClose, Factor, Per, 1 );
         ColorST = IIf( SuperTrend < HaClose, colorGreen, IIf( SuperTrend > HaClose, colorRed, colorBlack ) );
     }
     else
     {
         SuperTrend = fSuperTrend( High, Low, Close, Factor, Per, 0 );
         ColorST = IIf( SuperTrend < Close, colorGreen, IIf( SuperTrend > Close, colorRed, colorBlack ) );
     }

     Plot( SuperTrend, "SuperTrend", ColorST, styleStaircase | styleThick | styleNoRescale | styleNoTitle );
_SECTION_END();
// Code by @Loss_Lover for https://www.traderji.com/community/threads/seek-afl-coding-expertise.107862/post-1350642
MACD using Standard or HA Calculations
C-like:
function fMACD( cTyp, fPer, sPer, sigPer )
{
     if( cTyp )
     {
         HaClose = ( O + H + L + C ) / 4;
         HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
         HaHigh = Max( H, Max( HaClose, HaOpen ) );
         HaLow = Min( L, Min( HaClose, HaOpen ) );

         arr = ( HaHigh + HaLow ) / 2; // Use this
         //arr = HaClose; // Or this
         VarSet( "CustMACD", EMA( arr, fPer ) - EMA( arr, sPer ) );
         VarSet( "CustSignal", EMA( VarGet( "CustMACD" ), sigPer ) );
     }
     else
     {
         arr = ( H + L ) / 2; // Use this
         //arr = C; // Or this
         VarSet( "CustMACD", EMA( arr, fPer ) - EMA( arr, sPer ) );
         VarSet( "CustSignal", EMA( VarGet( "CustMACD" ), sigPer ) );
     }
}

_SECTION_BEGIN( "MACD using Standard or HA Calculations" );
     Version( 6.0 );

     CalcTyp = ParamToggle( "Calculation Type:", "Standard|Heikin-Ashi", 0 );
     FastPer = Param( "Fast EMA Per", 12, 1, 100, 1 );
     SlowPer = Param( "Slow EMA Per", 26, 1, 100, 1 );
     SignalPer = Param( "Signal Per", 9, 1, 100, 1 );

     fMACD( CalcTyp, FastPer, SlowPer, SignalPer );

     Plot( VarGet( "CustMACD" ), "MACD", colorOrange );
     Plot( VarGet( "CustSignal" ), "Signal", colorWhite );
     Plot( VarGet( "CustMACD" ) - VarGet( "CustSignal" ), "", colorLightBlue, styleHistogram | styleThick );
_SECTION_END();
// Code by @Loss_Lover for https://www.traderji.com/community/threads/seek-afl-coding-expertise.107862/post-1350642
When you make a million with these, pay me 10% then :)

Edit Reason: Updated a bit.
 
Last edited:
#19
Help me with this AFL need
Vwma
Daily current
Daily previous
Week current
Week previous
Month current
Month previous
Quarter current
Quarter previous
Half yearly current
Half yearly previous
Yearly current
Yearly previous
With names coming along with lines like dp dc
WC WP
MP
MC
Qc qp
Hp
Hv


Yep
Tec
Help ful l for delivery basis
What is this???
Does anyone need to introduce you to GOOGLE? A simple search will help more than asking.
 

Similar threads