[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: help needed on adx coding.



PureBytes Links

Trading Reference Links

Prashant 
have you seen this? +di will cross -di, Turquoise crosses Pink

//Trend Following Systems DO NOT work when ADX is Below 20 - Tech 
Analysis A-Z; page 120

P1 = Param("Period",10,0,100,1);
MyPDI= PDI(P1);//Positive Directional Indicator
MyMDI= MDI(P1);//Negative Directional Indicator (Minus)
MyADX= ADX(P1);//Average Directional Movement Index
//Green ADX Line=Rising; Red ADX Line=Falling
//Trend Following Systems DO NOT work when ADX is Below 20 
col = IIf( MyADX > Ref( MyADX, -1 ), colorGreen, colorRed);
Plot( MyPDI,"+DI",colorTurquoise, styleLine);
Plot( MyMDI,"-DI",colorPink, styleLine);
Plot( MyADX,"ADX",col, styleLine);
Title=Name()+ " " + Date() + " Price: " + C + EncodeColor
(colorIndigo) +"  ADX" + WriteVal( MyADX )+ EncodeColor
(colorSeaGreen) + "  +DMI" + WriteVal( MyPDI )+ EncodeColor
(colorPink) + "  -DMI" + WriteVal( MyMDI );

Tomasz gave you everything to figure it out, he nor I have the time 
to do YOUR work.

**********Fred Tonetti posted 
You supply:
- The array in the first statement ( Assumedly Price )
- The Indicator in the Calc = statement
- The Goal in the Goal = statement
... It will return in Explore the value needed in the array in the
next bar to have the indicator meet the goal in the next bar.
This is set up for use with a typical MACD but can be easily modified
for use with any indicator you can design.

P0 = C;
Acc = 0.00001;
LVBI = LastValue(BarIndex());
Mult = 1;

for (i = 0; i < 10; i++)
{
If (P0[LVBI] >= 1)
i = 99;
else
{
P0 = P0 * 10;
Mult = Mult * 10;
}
}

P1 = Ref(P0, 1);
UpDn = 100 * P1[LVBI];

for (i = 0; i < 200; i++)
{
Calc = EMA(P1,12)-EMA(P1,26);
Goal = EMA(EMA(P1,12)-EMA(P1,26),9);

if (Calc[LVBI] < Goal[LVBI])
P1[LVBI] = P1[LVBI] + UpDn;
else
P1[LVBI] = P1[LVBI] - UpDn;
UpDn = UpDn / 2;
if (UpDn <= Acc)
{
j = i;
i = 99999;
}
}

Accuracy = 100 * (abs(Goal[LVBI] - Calc[LVBI]) / Goal[LVBI]);

Filter = BarIndex() == LVBI;

AddColumn(Mult, "Multiplier", 1.0);
AddColumn(Calc[LVBI - 1] / Mult, "Curr Ind Val", 1.9);
AddColumn(Goal / Mult, "Goal Ind Val", 1.9);
AddColumn(Calc / Mult, "Calc Ind Val", 1.9);
AddColumn(j, "Iterations", 1.0);
AddColumn(Accuracy, "Accuray (%)", 1.9);
AddColumn(Ref(P1, -1) / Mult, "Current Array", 1.9);
AddColumn(P1 / Mult, "Needed Array", 1.9);

*************doggy2050 posted 
Code for 'Reverse Engineer RSI' in AFL:

_SECTION_BEGIN("Reverse Engineer RSI");
Value = Param("RSI value", 50, 1, 100, 0.1 );
WildPer = Param("Time periods", 14, 1, 100 );
ExpPer = 2 * WildPer - 1;
AUC = EMA( Max( C - Ref( C, -1 ), 0 ), ExpPer );
ADC = EMA( Max( Ref( C, -1 ) - C, 0 ), ExpPer );
x = (WildPer - 1) * ( ADC * Value / (100-Value) - AUC);
RevEngRSI = IIf( x >= 0, C + x, C + x * (100-Value)/Value );
//Plot( Close, Date()+", Close ", colorBlack, styleBar );
Plot( RevEngRSI,"Reverse Eng. RSI( "+WriteVal(WildPer,1.0)
+", "+WriteVal(Value, 1.2)+" )",colorGreen );
_SECTION_END();

***************dingo posted
// RevEngTrendRSI

RSIperiod = 14;
wper = 14;
Day1 = Param("day for point 1", 12, 1, 31, 1 );
Month1 = Param("month for point 1", 10, 1, 12, 1 );
Year1 = Param("year for point 1", 1990, 1950, 2150, 1 );

Day2 = Param("day for point 2", 9, 1, 31, 1 );
Month2 = Param("month for point 2", 10, 1, 12, 1 );
Year2 = Param("year for point 2", 1992, 1950, 2150, 1 );

Date1 = Day1 == Day() AND Month1 == Month() AND Year1 == Year();
Date2 = Day2 == Day() AND Month2 == Month() AND Year2 == Year();
i = BarsSince( Date1 );
j = BarsSince( Date2 );
RSI1 = ValueWhen( Date1, RSI( RSIperiod ) );
RSI2 = ValueWhen( Date2, RSI( RSIperiod ) );
Value = Min(Max((RSI2-RSI1)*(i+1)/(i-j)+RSI1, 1 ), 99 );
AUC = Wilders( Max( C - Ref( C, -1 ), 0 ), wper );
ADC = Wilders( Max( Ref( C, -1 ) - C, 0 ), wper );
x = ( wper - 1 )*( ADC * Value/(100-Value)-AUC);

RevEngTrendRSI = IIf( x >= 0, C + x, C + x*(100-Value)/Value );

Plot( Close, Date() + ", Close", colorBlack, styleCandle );
Plot( RevEngTrendRSI, "Reverse Trend RSI", colorRed );

*************8someone else wrote
Thanks everyone. The reverse RSI formula is exactly what I was looking
for in this case. I also like the search function (very creative). I
did notice the binary implementation. I will definitely keep a link to
this for future reference.

Dingo's post for me would be the easiest to combine with the first 
example I got from ami library.
****************I posted get to work.
kim



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/