Traderji.com - Discussion forum for Stocks Commodities & Forex

AmiBroker formula Language

Discuss AmiBroker formula Language at the AmiBroker within the Traderji.com - Discussion forum for Stocks Commodities & Forex; I saw price(all-in-one)indiactor shows o,h,l,c in tips show. I copied and made another custom price ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > TOOLS & RESOURCES > Software > AmiBroker

Notices


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #201  
Old 21st May 2008, 08:37 PM
Member
 
Join Date: Dec 2005
Posts: 937
Thanks: 419
Thanked 412 Times in 197 Posts
lvgandhi is just really nicelvgandhi is just really nicelvgandhi is just really nicelvgandhi is just really nicelvgandhi is just really nice
Reputation: 436
Default Re: AmiBroker formula Language

I saw price(all-in-one)indiactor shows o,h,l,c in tips show. I copied and made another custom price indicator, with out changing anything in the price section. But the custom indicator doesn't show o,h and l. It only shows close. What should I do to get, o,h and l in tips. I am using ami 5
Reply With Quote
Sponsored Links
  #202  
Old 22nd May 2008, 10:09 AM
Member
 
Join Date: May 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Anthony is on a distinguished road
Reputation: 10
Default Pibot Finder Formula need help

Any body can help me to add by and sell , so I can use this formula for scanner.

_SECTION_BEGIN("Pivot Finder");
/* **********************************

Code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);

// -- Title.

Title = Name() + " (" + StrLeft(FullName(), 15) + ") O: " + Open + ",

H: " + High + ", L: " + Low + ", C: " + Close;

// -- Plot basic candle chart

PlotOHLC(Open, High, Low, Close,

"BIdx = " + BarIndex() +

"\n" + "O = " + O + "\n"+"H = "+ H + "\n"+"L = " + L

+ "\n"+"C ",

colorBlack, styleCandle);

GraphXSpace=7;

// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for future use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = HHVBars(H, nBars);

aLLVBars = LLVBars(L, nBars);

aHHV = HHV(H, nBars);

aLLV = LLV(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in future version

for (i=0; i<farback; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}

// -- Dump inventory of high pivots for debugging

/*

for (k=0; k<nHPivs; k++) {

_TRACE("High pivot no. " + k

+ " at barindex: " + aHPivIdxs[k] + ", "

+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

DateTime(), 1), formatDateTime)

+ ", " + aHPivHighs[k]);

}

*/

// -- OK, let's plot the pivots using arrows

PlotShapes(

IIf(aHPivs==1, shapeDownArrow, shapeNone), colorRed, 0,

High, Offset=-15);

PlotShapes(

IIf(aLPivs==1, shapeUpArrow , shapeNone), colorGreen, 0,

Low, Offset=-15);

_SECTION_END();
Reply With Quote
  #203  
Old 22nd May 2008, 01:07 PM
Member
 
Join Date: May 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Anthony is on a distinguished road
Reputation: 10
Default Re: AmiBroker formula Language

_SECTION_BEGIN("A CandlestickTargeting Your Pattern");

function msPattPos( element )
{
Value1 = Ref( H, -1 );
Value2 = Ref( L, -1 );
Value3 = ( Value1 + Value2 )/2;
Dist = Ref( ATR( 10 ), -1 );
Value4 = Value1 + Dist;
Value5 = Value2 - Dist;

result = IIf( element < Value5, 0,
IIf( element < Value2, 1,
IIf( element < Value3, 2,
IIf( element < Value1, 3,
IIf( element < Value4, 4,
5 ) ) ) ) );

return result;
}

function msPattToText( patt )
{
result = WriteIf( patt == 0, " is below previous (Low - ATR 10) ",
WriteIf( patt == 1, " is above (at) previous (Low - ATR 10) and below previous Low ",
WriteIf( patt == 2, " is above (at) previous Low and below previous Midpoint ",
WriteIf( patt == 3, " is above (at) previous Midpoint and below previous High ",
WriteIf( patt == 4, " is above (at) previous High and below (High + ATR 10) ",
" is above (at) previous (High + ATR(10) " ) ) ) ) );

return result;
}

function msRecognize()
{
return 1000 * msPattPos( Open ) + 100 * msPattPos( High ) + 10 * msPattPos( Low ) + msPattPos( Close );
}

function msPatternDescription( patt )
{
return "Open: " + msPattToText( round( ( patt / 1000 ) % 10 ) ) + "\n" +
"High: " + msPattToText( round( ( patt / 100 ) % 10 ) ) + "\n" +
"Low: " + msPattToText( round( ( patt / 10 ) % 10 ) ) + "\n" +
"Close: " + msPattToText( round( patt % 10 ) );
}

patts = msRecognize();

// by default use pattern occuring at selected bar
DesiredPattern = SelectedValue( patts );

// if you want manual-entry of pattern code from parameter dialog
// then uncomment the line below
//DesiredPattern=Param("Pattern to look for", 3434, 0, 5555, 0 );

Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g", O, H, L, C);
Title = Title + "\nPattern code is : " + DesiredPattern + "\n" +
msPatternDescription( DesiredPattern );

Plot( C, "Price", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );



PattCloseAbove = DesiredPattern == patts AND Ref( Close > Open, 1 );
PattCloseBelow = DesiredPattern == patts AND Ref( Close < Open, 1 );

PlotShapes( ( DesiredPattern == patts ) * shapeCircle ,
IIf( PattCloseAbove, colorGreen,
IIf( PattCloseBelow, colorRed, colorBlue ) ),
0, High, 30 );

NumPatterns = LastValue( Cum( DesiredPattern == patts ) );

NumPattCloseAbove = LastValue( Cum( PattCloseAbove ) );
NumPattCloseBelow = LastValue( Cum( PattCloseBelow ) );
NumPattCloseEqual = NumPatterns - NumPattCloseAbove - NumPattCloseBelow;

Title = Title +
"\n\nTotal number of Patterns: " + NumPatterns +
"\n% on Total Bars: " + 100 * NumPatterns/BarCount +
"\nIn the next bar\n" +
EncodeColor(colorGreen) +
"Close has been above the open " + NumPattCloseAbove +
" (" + NumPattCloseAbove / NumPatterns + "%) times\n" +
EncodeColor(colorRed) +
"Close has been below the open " + NumPattCloseBelow + " (" +
NumPattCloseBelow / NumPatterns +" %) times\n" +
EncodeColor(colorBlue) +
"Close has been equal to the open " + NumPattCloseEqual + " (" +
NumPattCloseEqual / NumPatterns +" %)times";

_SECTION_END();
Reply With Quote
  #204  
Old 23rd May 2008, 07:20 AM
Member
 
Join Date: May 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Anthony is on a distinguished road
Reputation: 10
Default Re: AmiBroker formula Language

Please take a look this chart maybe will help you.


_SECTION_BEGIN("A CandlestickTargeting Your Pattern");

function msPattPos( element )
{
Value1 = Ref( H, -1 );
Value2 = Ref( L, -1 );
Value3 = ( Value1 + Value2 )/2;
Dist = Ref( ATR( 10 ), -1 );
Value4 = Value1 + Dist;
Value5 = Value2 - Dist;

result = IIf( element < Value5, 0,
IIf( element < Value2, 1,
IIf( element < Value3, 2,
IIf( element < Value1, 3,
IIf( element < Value4, 4,
5 ) ) ) ) );

return result;
}

function msPattToText( patt )
{
result = WriteIf( patt == 0, " is below previous (Low - ATR 10) ",
WriteIf( patt == 1, " is above (at) previous (Low - ATR 10) and below previous Low ",
WriteIf( patt == 2, " is above (at) previous Low and below previous Midpoint ",
WriteIf( patt == 3, " is above (at) previous Midpoint and below previous High ",
WriteIf( patt == 4, " is above (at) previous High and below (High + ATR 10) ",
" is above (at) previous (High + ATR(10) " ) ) ) ) );

return result;
}

function msRecognize()
{
return 1000 * msPattPos( Open ) + 100 * msPattPos( High ) + 10 * msPattPos( Low ) + msPattPos( Close );
}

function msPatternDescription( patt )
{
return "Open: " + msPattToText( round( ( patt / 1000 ) % 10 ) ) + "\n" +
"High: " + msPattToText( round( ( patt / 100 ) % 10 ) ) + "\n" +
"Low: " + msPattToText( round( ( patt / 10 ) % 10 ) ) + "\n" +
"Close: " + msPattToText( round( patt % 10 ) );
}

patts = msRecognize();

// by default use pattern occuring at selected bar
DesiredPattern = SelectedValue( patts );

// if you want manual-entry of pattern code from parameter dialog
// then uncomment the line below
//DesiredPattern=Param("Pattern to look for", 3434, 0, 5555, 0 );

Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g", O, H, L, C);
Title = Title + "\nPattern code is : " + DesiredPattern + "\n" +
msPatternDescription( DesiredPattern );

Plot( C, "Price", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );



PattCloseAbove = DesiredPattern == patts AND Ref( Close > Open, 1 );
PattCloseBelow = DesiredPattern == patts AND Ref( Close < Open, 1 );

PlotShapes( ( DesiredPattern == patts ) * shapeCircle ,
IIf( PattCloseAbove, colorGreen,
IIf( PattCloseBelow, colorRed, colorBlue ) ),
0, High, 30 );

NumPatterns = LastValue( Cum( DesiredPattern == patts ) );

NumPattCloseAbove = LastValue( Cum( PattCloseAbove ) );
NumPattCloseBelow = LastValue( Cum( PattCloseBelow ) );
NumPattCloseEqual = NumPatterns - NumPattCloseAbove - NumPattCloseBelow;

Title = Title +
"\n\nTotal number of Patterns: " + NumPatterns +
"\n% on Total Bars: " + 100 * NumPatterns/BarCount +
"\nIn the next bar\n" +
EncodeColor(colorGreen) +
"Close has been above the open " + NumPattCloseAbove +
" (" + NumPattCloseAbove / NumPatterns + "%) times\n" +
EncodeColor(colorRed) +
"Close has been below the open " + NumPattCloseBelow + " (" +
NumPattCloseBelow / NumPatterns +" %) times\n" +
EncodeColor(colorBlue) +
"Close has been equal to the open " + NumPattCloseEqual + " (" +
NumPattCloseEqual / NumPatterns +" %)times";

_SECTION_END();





Quote:
Originally Posted by omkarmango View Post
white candle = Prices close above open.
black candle = Prices close below open.

in simple english, AFL to predict, will the stock go up tommorrow or down ?

I do not think such AFL exists to predict this.

If exists, nobody will share it even for Million $.

Because he would be already a BILLIONAIRE.
Reply With Quote
  #205  
Old 3rd June 2008, 06:04 PM
Member
 
Join Date: May 2008
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
sankar17f is on a distinguished road
Reputation: 10
Default Re: AmiBroker formula Language

Hi,
i am a novice in AFL programming. I found the following metastock code in the web. Kindly help to convert this code in to AFL.
Short Sell Strategy

MetaStock Explorer Formula:
Use this formula to explore and search stocks good for short selling...

Col A:
O - C +
Ref(O - C,-1) +
Ref(O - C,-2)

Filter:
C > O AND
Ref(C,-1) < Ref(O,-1) AND
Ref(C,-2) < Ref(O,-2) AND

(BBandTop(C,20,S,2) - BBandBot(C,20,S,2))/2 + BBandBot(C,20,S,2) > C AND

Ref((BBandTop(C,20,S,2) - BBandBot(C,20,S,2))/2 + BBandBot(C,20,S,2),-1) > Ref(C,-1) AND

Ref((BBandTop(C,20,S,2) - BBandBot(C,20,S,2))/2 + BBandBot(C,20,S,2),-2) > Ref(C,-2)


Thanks in advance.
Reply With Quote
  #206  
Old 4th June 2008, 06:48 PM
Member
 
Join Date: Dec 2006
Posts: 273
Thanks: 5
Thanked 5 Times in 3 Posts
omkarmango is on a distinguished road
Reputation: 43
Default Re: AmiBroker formula Language

Quote:
Originally Posted by Anthony View Post
Please take a look this chart maybe will help you.


_SECTION_BEGIN("A CandlestickTargeting Your Pattern");

function msPattPos( element )
{
Value1 = Ref( H, -1 );
Value2 = Ref( L, -1 );
Value3 = ( Value1 + Value2 )/2;
Dist = Ref( ATR( 10 ), -1 );
............................
...........................................
_SECTION_END();

Please go through the whole page (No.11) & u'll get idea what the discussion was all about.

Thanx ...but AFL on two-bar patterns wont be helpful anyway (though I am not looking for any formula or indicator).
Reply With Quote
  #207  
Old 5th June 2008, 11:31 PM
Member
 
Join Date: Jul 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
coolabhi99 is on a distinguished road
Reputation: 20
Default Need Help

Dear All,

I am an Advanced GET EOD user for the last few years but recently started using Ami as well and found AMI very flexible.

I have a small problem as of now while using AMI. I buy the EOD DATA from Viratech , the guys who sold Advanced GET to me.

My problem is as follows :

Each scrip in Viratech data has a unique number. For Eg, Infosys Future is 70006345 where as Infosys in NSE is 700000069. Now if i simply type Infosys i can access the chart in Advanced Get.

But in Ami i only get the scrip numbers. SO in case i run an exploration and the results display the scrip codes instead of names and it is very difficult for me to figure out which scrip it is.

Can anyone suggest what to do or is there an AFL which can convert the Scrip Codes to Scrip Names??

Look forward to the help.

Thanks in Advance,

Abhi
Reply With Quote
  #208  
Old 11th June 2008, 06:24 AM
Member
 
Join Date: Sep 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
SRJC is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

HI
The following is HEIKEN ASHI Afl.

////////////////////////////////////
//
// Heikin_Ashi For Amibroker
//
////////////////////////////////////

SetChartBkColor(ParamColor("Outer panel color ",colorPaleBlue)); // color of outer border

SetChartBkGradientFill( ParamColor("Inner panel color upper half", colorPaleBlue),ParamColor("Inner panel color lower half",

colorPaleBlue)); // color of inner panel

HaClose =EMA((O+H+L+C)/4,3);

HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );

HaHigh = Max( H, Max( HaClose, HaOpen ) );

HaLow = Min( L, Min( HaClose, HaOpen ) );

PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Modified " + Name(), colorBlue, styleCandle | styleNoLabel );

Title = "\n" + "" + Name() + ", " + Interval(2) + ", " + Date() + "\n";

Can senior members provide color coding for the same: like Blue for hollow candles with upper shadows, Red for filled candles with lower shadows and diffrent color for body with lower and upper shadows?

If the information is already available, can you provide a link to it.

Kindly also add Buy and sell signals with arrows and prices.

SRJC

Last edited by SRJC; 11th June 2008 at 11:15 AM.
Reply With Quote
  #209  
Old 13th June 2008, 09:57 PM
Member
 
Join Date: May 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Anthony is on a distinguished road
Reputation: 10
Default Re: AmiBroker formula Language

Hai BVPraveen
I really glad found this forum, hi Praveen I think you can make a blog for basic teaching to guide as a newbie to know about AFL. I know click Help we can found in AB software but your tutorial more easy to follow.

Warm Regards,
Reply With Quote
  #210  
Old 14th June 2008, 09:33 AM
Member
 
Join Date: Feb 2008
Posts: 73
Thanks: 0
Thanked 1 Time in 1 Post
Bhulokeshwar is on a distinguished road
Reputation: 11
Default Re: AmiBroker formula Language

Hi
I want technical analysis including but and sell signals for INTRADAY for use in MCX,NCDEX and NSE.
1.Is AM supports for intraday,if so which version (i means standerd or proffesional ), i have to download from website ?
2.which one i have to use to data tranfer from odin diet karvy and sharekhan trade tiger
kindly help me please
Bhulokeshwar
Reply With Quote
Sponsored Links

Reply

Bookmarks


Advertise Here


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads for: AmiBroker formula Language
Thread Thread Starter Forum Replies Last Post
need help on formula cmlee MetaStock 23 8th October 2007 07:55 PM
Metastock ,Metatrader & Amibroker indicator formula saji oommen MetaStock 0 4th June 2006 06:35 PM
Metastock language help Ropewalker MetaStock 4 1st November 2005 09:16 PM
TradeStation & MetaStock Formula Language bikertrader MetaStock 4 10th December 2004 01:50 PM


All times are GMT +5.5. The time now is 11:40 AM.

Indemnity, Disclaimer & Disclosure Notice:
• By visiting Traderji.com you indicate your acceptance of our Forum Rules Disclaimer & Disclosure and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum.
Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of this information.
Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
• All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy of information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. If you find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Copyright © 2001 - 2008, Traderji.com All Rights Reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com