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; Originally Posted by kuriako Ami doesn't support default values for parameters of user-defined functions/procedures. That ...


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

Notices


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #171  
Old 12th December 2007, 09:35 PM
Member
 
Join Date: Nov 2006
Posts: 1,496
Thanks: 55
Thanked 69 Times in 38 Posts
kkseal will become famous soon enoughkkseal will become famous soon enough
Reputation: 133
Default Re: AmiBroker formula Language

Quote:
Originally Posted by kuriako View Post
Ami doesn't support default values for parameters of user-defined functions/procedures. That is to say the in-built MACD(fpd=12, spd=26) works, but an user-defined KMACD(fpd=12, spd=26) does not.


This may help!

function KMACD(IP1,IP2)
{
if(IP1=null and IP2=null)
{IP1=____;
IP2=____;// default value here;
}
.................................
return result;
}

Hope this could help!
Tried that route (and also the IsNull function) but when you call the function - like in Plot(KMACD(),...) - it gives a 'Missing Arguments' error. (Actually the value-checking code is within the function whereas the argument check is done at the Call level itself; so doesn't work)

BTW, should use IP1 == null and IP2 == null or else Null will be assigned to args IP1 & IP2 irrespective of values passed.

Regards,
Kalyan.

Last edited by kkseal; 12th December 2007 at 09:45 PM.
Reply With Quote
Sponsored Links
  #172  
Old 12th December 2007, 10:28 PM
Member
 
Join Date: Oct 2006
Location: Cochin
Posts: 290
Thanks: 5
Thanked 0 Times in 0 Posts
kuriako will become famous soon enough
Reputation: 51
Smile Re: AmiBroker formula Language

Can u please try function with "No parameters passed"

ie: function KMACD()
{if(IP1==0....
........
}

Arguments can be passed with universal variables!
Reply With Quote
  #173  
Old 13th December 2007, 02:16 PM
Member
 
Join Date: Nov 2006
Posts: 1,496
Thanks: 55
Thanked 69 Times in 38 Posts
kkseal will become famous soon enoughkkseal will become famous soon enough
Reputation: 133
Default Re: AmiBroker formula Language

Quote:
Originally Posted by kuriako View Post
Can u please try function with "No parameters passed"

ie: function KMACD()
{if(IP1==0....
........
}

Arguments can be passed with universal variables!
When i use Plot(KMACD(),...) with no values within the parenthesis it's the same as calling the function with "No parameters/argument (values) passed" This as i said generates a " Missing Arguments" error. If i exclude the parenthesis and just use KMACD then it will be treated as an undefined identifier.

I had thought of the global variable route as well. Suppose i have an AFL called K_defaults.afl where all the default values are declared/defined. Let's say the defaults for the KMACD are def_fpd = 12 & def_spd = 26. Now i include this file everywhere i want to use the KMACD (a hassle in itself). Even then when i want to use the default values i'll have to use the function call as KMACD(def_fpd, def_spd). So no advantage. I might as well simply use KMACD(12,26) (saving me the first hassle).

Anyways, as i said, no big deal. And thanks for your suggestion.

Regards,
Kalyan.
Reply With Quote
  #174  
Old 13th December 2007, 10:01 PM
Member
 
Join Date: Oct 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
sharadsir is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

hi to all,
i m new and i need:
today volume is greater than yesterday volume by 20 or 30%
to day price is greater than yesterday price
i want to create a corelation between price and volume
thnx to all for gr8 contribution
sharad
Reply With Quote
  #175  
Old 15th December 2007, 07:06 AM
Member
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
loverboyy is on a distinguished road
Reputation: 25
Default Re: AmiBroker formula Language

Hi all , can someone help me

How do i plot
1) A Sell arrow "when K% Cross down D% and it above 75% level"
2) A buy arrow " when K% Cross up D% and it below 25% level"

_SECTION_BEGIN("Slow Stochastic");
/*Slow Stochastic and Trendlines
for Indicator Builder,
by Dimitris Tsokakis*/
D1=14;
MaxGraph=8;
ST3=StochK(D1);
ST33=StochD(D1);
Graph0=ST3;
Graph1=ST33;
Title=Name()+" - %K="+WriteVal(st3,FORMAT=1.2)+", %D="+
WriteVal(ST33,FORMAT=1.2)+
WriteIf(Cross(st3,st33)," POSITIVE CROSS"," ")+
WriteIf(Cross(ST33,ST3)," NEGATIVE CROSS","");
x = Cum(1);
per = 0.1;
s1=st33;
s11=st33;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;
Graph6 = IIf(x>startt-1 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10);
Graph6Style = 1;
Graph6Color = 1;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
Graph7 = IIf(x>startT1-1 AND TRENDLINER>0 AND
TRENDLINER<100,trendlineR,-1e10);
Graph7Style = 1;
Graph7Color = 1;
PlotGrid( 75, colorGreen );
PlotGrid( 25, colorGreen );
_SECTION_END();
Reply With Quote
  #176  
Old 25th December 2007, 12:58 AM
Member
 
Join Date: Dec 2006
Location: Puri
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
mishphar is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

Hi Kalyan i am new the alf progamming so please
help me to write the amiborker formula
I want to filter the data condition is below

advance price =movingaverage(close,10)
decline price =movingaverage(close,10)
x=advance price/decline price
if x>.75 then conditionl=true
if x<.50 then conditionl=false
if conditionl=true and rsi(close,8) crosses above 30 then buy on close
if rsi(close,8) crosses below 65 then exitlong on close
if conditionl=false then exitlong on close

Last edited by mishphar; 25th December 2007 at 09:21 AM.
Reply With Quote
  #177  
Old 25th December 2007, 02:19 PM
Member
 
Join Date: Nov 2006
Posts: 1,496
Thanks: 55
Thanked 69 Times in 38 Posts
kkseal will become famous soon enoughkkseal will become famous soon enough
Reputation: 133
Default Re: AmiBroker formula Language

Quote:
Originally Posted by mishphar View Post
Hi Kalyan i am new the alf progamming so please
help me to write the amiborker formula
I want to filter the data condition is below

advance price =movingaverage(close,10)
decline price =movingaverage(close,10)
x=advance price/decline price
if x>.75 then conditionl=true
if x<.50 then conditionl=false
if conditionl=true and rsi(close,8) crosses above 30 then buy on close
if rsi(close,8) crosses below 65 then exitlong on close
if conditionl=false then exitlong on close
From the pseudo-code you've provided x will always be equal to 1.

Seemingly, what you want is a MA for the UP days & a MA for the DN days. (Pretty much what the RSI does with the momentum, only it doesn't stop there)
However this needs confirmation from your side.

Regards,
Kalyan.

Last edited by kkseal; 25th December 2007 at 02:34 PM.
Reply With Quote
  #178  
Old 25th December 2007, 04:13 PM
Member
 
Join Date: Dec 2006
Location: Puri
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
mishphar is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

Hi kalyan thnx for quick response
the formula describe in "Trading Secrets of Inner cirlcle" by Andrew Goodwin book which is

Market Breadth Filtered 8 day RSI:
Rules:
1) Calculate the 10 day simple moving average of the number of advancing issues on
the NYSE. This number is available from most quote services, brokers and financial
television tickers. A ten day moving average is calculated by adding the last
ten days of advances and dividing this sum by 10.
2) Calculate the 10 day simple moving average of the number of declining issues on
the NYSE. Follow the same procedure that you did to calculate the 10 day moving
average of advances.
12 Trading Secrets of the Inner Circle
3) Divide the 10 day average of advances by the 10 day average of declines.
4) If the value of the division is greater than .75 or 75% then our market breadth filter
is considered positive.
5) If the value of the division is less than .50 then our market breadth filter is considered
negative.
6) If the breadth filter is positive then buy the S&P 500 contracts on the close of the
day when the 8 day RSI crosses from below to above 30.
7) Exit your long position if the 8 day RSI crosses from above to below 65.
8) Also exit your long position if the market breadth filter changes from positive to
negative.
Results and discussion of the Breadth Filtered 8 day RSI
This system adds a trend filter designed to get us out of the trade if market breadth
deteriorates while we are in the trade, but the 8 day RSI fails to provide us with an exit.
This technological advance allows us to get out of bad trades more quickly than we
would if we were trading the 8 day RSI system. Profit factor rises to 4.55 from the 3.29
of the basic system. Our net profit increases by $28,000 and our maximum drawdown
shrinks by nearly 65%. This system clearly improves the result of the basic system and
gives us a safer way to trade. However, the W/L ratio is still too low at .71. So let us
move to the "Market Wizard" version.
Treasury Note and Treasury Bill Filtered 8 day RSI:
These filters were adapted from a concept discussed by the great S&P trader, Marly
Schwartz who was interviewed in the trading book "Market Wizards." Schwartz suggests
trading S&P futures when both bonds and short paper are above their moving
averages. This model draws on Schwartz's concept, but we have added our own twist.
Market Wizard Filter 13
Rules:
1) Each Friday, record the close of the CBOT's ten-year note future. When the
Friday close of the ten-year note is greater than its 40 week moving average then
the note filter is positive. If Friday is a holiday, use whatever close is the last close
of the trading week.
2) Each Friday, record the close of the Treasury bill future. When Friday's closing
T'bill future price is greater than its 40 week moving average, then the short paper
filter is positive.
3) If the note filter and the bill filter are both positive then the interest rate component
is positive.
4) If the note filter and the bill filter are both negative then the interest rate composite
is negative.
5) If either the note filter or the bill filter is positive while the other is negative, the
last reading of the interest rate composite stays the same. A change in the reading
is only possible if both the note and the bill filter are above or below their moving
averages simultaneously at Friday's close.
6) If the interest rate composite is bullish, buy on the close of the day when the 8 day
RSI crosses from below to above the 40 buy line.
7) Exit your long trade if the 8 day RSI crosses from above to below the 75 sell line.
8) Exit your long trade if the interest rate composite changes from positive to negative
even if RSI has not given an exit signal yet.
Reply With Quote
  #179  
Old 25th December 2007, 08:23 PM
Member
 
Join Date: Nov 2006
Posts: 1,496
Thanks: 55
Thanked 69 Times in 38 Posts
kkseal will become famous soon enoughkkseal will become famous soon enough
Reputation: 133
Default Re: AmiBroker formula Language

Mishphar, now that you have everything for the coding try doing it on your own (or else tomorrow you may come across another 'secret' & cry help for the coding)

Look up the following in Ami Help

Functions : AdvIssues, DecIssues, Cross

Reserved variables : Buy, Sell, Filter

Cut out all the fluff (colouring,shapes etc.) and just concentrate on the basic code. Not all that difficult.

Regards,
Kalyan.
Reply With Quote
  #180  
Old 26th December 2007, 12:36 AM
Member
 
Join Date: Dec 2006
Location: Puri
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
mishphar is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

Yes Kalyan u r correct but I am completely new for this programming it is not that I will grasp in one day everything I am trying at my best and reading now all the alf functions so it will take some time just u write the code once then i will try to practice next.
thnx for ur encouraging word.
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 12:00 PM.

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