Traderji.com - Discussion forum for Stocks Commodities & Forex

Need Help with this AFL

Discuss Need Help with this AFL at the AmiBroker within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Hi Ajax. look at the first line: farback= 70 ; //Param("How Far back to go",100,50,5000,10); ...


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

Notices


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #21  
Old 13th March 2008, 10:28 AM
Member
 
Join Date: Jan 2007
Posts: 78
Appreciation: 20
ashutosh.krsrivastava is on a distinguished road
Default Re: Need Help with this AFL

Hi Ajax.
look at the first line:
farback= 70 ; //Param("How Far back to go",100,50,5000,10);

if number of quotes is less than 70, then the error will occur. due to

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

curBar = (BarCount - 1) - i;

Try with number of bars greater than 70 or 80 and everything will be fine i think.
regards
ashutosh
Reply With Quote
  #22  
Old 13th March 2008, 11:19 AM
Member
 
Join Date: May 2006
Posts: 478
Appreciation: 36
Ajax is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by ashutosh.krsrivastava View Post
Hi Ajax.
look at the first line:
farback= 70 ; //Param("How Far back to go",100,50,5000,10);

if number of quotes is less than 70, then the error will occur. due to

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

curBar = (BarCount - 1) - i;

Try with number of bars greater than 70 or 80 and everything will be fine i think.
regards
ashutosh
HI ASHUTOSH

TRIED WITH farback = 100, 1000, 10000
NO MATTER WHAT THE VALVE OF farback
THE ERROR IS THE SAME

AJAX
Reply With Quote
  #23  
Old 13th March 2008, 12:31 PM
Member
 
Join Date: Jan 2007
Posts: 78
Appreciation: 20
ashutosh.krsrivastava is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by Ajax View Post
HI ASHUTOSH

TRIED WITH farback = 100, 1000, 10000
NO MATTER WHAT THE VALVE OF farback
THE ERROR IS THE SAME

AJAX
I didnt mean farback = 100 or above
farback = 70 is okey. Its just that number of bars in the chart must be greater than 70. So one more thing you can try is set farback to 10, if number of bars in your chart is less than 70 or something.
regards
ashutosh
Reply With Quote
  #24  
Old 13th March 2008, 07:26 PM
Member
 
Join Date: Mar 2007
Posts: 65
Appreciation: 20
ramash is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by deedeed View Post
Hi Ashutosh,
Seems to be working perfect now. will keep watching for a couple of days and will ping you with the results.

cheers
deedeed.
hi deedeed,

i have seen your gann swing chart afl and tried to look for it in ami. But i don't get that swing lines but values comes clearly.

I am attaching the chart. kindly guide me where i went wrong. i use black as my background color in ami. So should i make any change in the afl also.

ramash
Attached Images
File Type: png rplswing.png (8.1 KB, 30 views)
Reply With Quote
  #25  
Old 14th March 2008, 10:28 AM
Member
 
Join Date: Jan 2007
Posts: 78
Appreciation: 20
ashutosh.krsrivastava is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by ramash View Post
hi deedeed,

i have seen your gann swing chart afl and tried to look for it in ami. But i don't get that swing lines but values comes clearly.

I am attaching the chart. kindly guide me where i went wrong. i use black as my background color in ami. So should i make any change in the afl also.

ramash
Hi Ramash,
just curious, what is the color of the swing line in your chart??
try to change the background color of your chart, or else post code..
regards
ashutosh
Reply With Quote
  #26  
Old 14th March 2008, 06:00 PM
Member
 
Join Date: Mar 2007
Posts: 65
Appreciation: 20
ramash is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by ashutosh.krsrivastava View Post
Hi Ramash,
just curious, what is the color of the swing line in your chart??
try to change the background color of your chart, or else post code..
regards
ashutosh
hi ashutosh,

thanks for your reply. am new to afl's. started writing few. came across gann swing chart afl here. and i tried it with ami. i have attached the screenshort of rpl above. I give u the code here. have not changed anything other than the values color display from your prev code.
I use black as my back ground color.

kindly clarify me.

ramash

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBrightGreen ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("gannswingchart");
/* Gann Swing chart v4 */
/* Last modified 24 Feb 2001 */
/* AFL implementation by */
/* (C)2001 Tomasz Janeczko */
/* one and two - bar reversal version */

/* Change this to 1 for two-bar mode */
twobarmode = 0;

outsidebar = Outside();
insidebar = H <= Ref( H, -1 ) AND L >= Ref( L, -1 ); // built-in inside() works with < > instead of <= >=

upbar = H > Ref( H, -1 ) AND L >= Ref( L, -1 );
downbar = L < Ref( L, -1 ) AND H <= Ref( H, -1 );

upbar2 = upbar OR ( outsidebar AND Ref( downbar, 1 ) ) ;
downbar2 = downbar OR ( outsidebar AND Ref( upbar, 1 ) );

Poi = outsidebar AND Ref( insidebar, 1 );
Poo = outsidebar AND Ref( outsidebar, 1 );
Pooi = Poo AND Ref( insidebar, 2 );
Poio = Poi AND Ref( outsidebar, 2 );
Poii = Poi AND Ref( insidebar, 2 );
Pooo = Poo AND Ref( outsidebar, 2 );
Poooi = Pooo AND Ref( insidebar, 3 );
Pooio = Pooi AND Ref( outsidebar, 3 );
Poioo = Poio AND Ref( outsidebar, 3 );

upbar3 = upbar2 OR ( Poi AND Ref( downbar, 2 ) );
downbar3 = downbar2 OR ( Poi AND Ref( upbar, 2 ) );

upbar4 = upbar3 OR ( Poo AND Ref( upbar, 2 ) );
downbar4 = downbar3 OR ( Poo AND Ref( downbar, 2 ) );

upbar5 = upbar4 OR ( Pooi AND Ref( upbar, 3 ) );
downbar5 = downbar4 OR ( Pooi AND Ref( downbar, 3 ) );

upbar6 = upbar5 OR ( Poio AND Ref( upbar, 3 ) );
downbar6 = downbar5 OR ( Poio AND Ref( downbar, 3 ) );

upbar7 = upbar6 OR ( Poii AND Ref( downbar, 3 ) );
downbar7 = downbar6 OR ( Poii AND Ref( upbar, 3 ) );

upbar8 = upbar7 OR ( Pooo AND Ref( downbar, 3 ) );
downbar8 = downbar7 OR ( Pooo AND Ref( upbar, 3 ) );

upbar9 = upbar8 OR ( Poooi AND Ref( downbar, 4 ) );
downbar9 = downbar8 OR (Poooi AND Ref( upbar, 4 ) );

upbar10 = upbar9 OR ( Pooio AND Ref( downbar, 4 ) );
downbar10 = downbar9 OR ( Pooio AND Ref( upbar, 4 ) );

upbar11 = upbar10 OR ( Poioo AND Ref( downbar, 4 ) );
downbar11 = downbar10 OR ( Poioo AND Ref( upbar, 4 ) );

fupbar = upbar11;
fdownbar = downbar11;

// Two-bar mode handling
fupbar = IIf( twobarmode, fupbar AND Ref( fupbar, 1 ), fupbar );
fdownbar = IIf( twobarmode, fdownbar AND Ref( fdownbar, 1 ), fdownbar );

/* Barcount since most recent up and down swings */
Us = BarsSince( fupbar );
Ds = BarsSince( fdownbar ) ;

Sd1 =IIf( Us==0, 1, IIf( Ds==0, -1, 0) );

Sd2 = IIf( Sd1 == 1, IIf( Ref( BarsSince(Sd1==1), -1) > Ref( BarsSince( Sd1 == -1), -1), 1, 0),
IIf( Sd1 == -1, IIf( Ref( BarsSince(Sd1==1),-1) < Ref( BarsSince( Sd1 == -1),-1), -1, 0), 0 ) );

g0 = ValueWhen( Sd2, Sd2 ); /* sample and hold non-zero values */

/* shift back one bar, add one dummy swing at the end and shift forward */
/* to ensure proper handling of the last swing */
lastbar = Cum(1) == LastValue( Cum(1) );
swinglevel = IIf( g0 == -1, HighestSince( Sd2 == 1, H ), LowestSince( Sd2 == -1, L ) );
swinglevel = IIf( lastbar, IIf( g0 == -1, LowestSince( Sd2 == -1, L ), HighestSince( Sd2 == 1, H )), Ref( swinglevel, 1 ) );

/* Gann Swing chart drawn here */
Graph1 = Ref( ValueWhen( Ref( Sd2 != 0, 1 ) OR lastbar, swinglevel , 0 ), -1 );
Graph1Style = 512+1024;
GraphXSpace = 10;

dist = 1.0*ATR(25);
for(i = 1; i <= BarCount - 1; i++){
IIf(swinglevel[i] == swinglevel[i -1], txtVal = 0 , txtVal = swinglevel[i] - swinglevel[i-1]);
Cntp = BarsSince(Cross(sd2, 0));
Cntn = BarsSince(Cross(0, sd2));
txtValStr = NumToStr(abs(txtVal), 1.2);
if(txtVal > 0) PlotText("" + txtValStr, i-(Cntp[i]+2)/2, swinglevel[ i ] + dist[ i ], colorYellow);
if(txtVal < 0) PlotText("" + txtValStr, i-(Cntn[i]+2)/2 , swinglevel[ i ] - dist[ i ], colorYellow);
}



/*
dist = 0.5*ATR(25);
for(i=1;i<=BarCount - 1; i++)
{
IIf(swinglevel[i] == swinglevel[i-1], txtVal = 0, txtVal = swinglevel[i]-swinglevel[i-1]);
txtValStr = NumToStr(abs(txtVal), 1.2);
if(txtVal >0) PlotText("" + txtValStr, i, swinglevel[i] + dist[i], colorYellow);
if(txtVal < 0) PlotText ("" + txtValStr, i-1, swinglevel[i] - dist[i], colorPink);
}

/* //Colourized price bars drawn here
Graph0 = Close;
Graph0Style = 128;
barcolor = IIf( outsidebar, 1, IIf( downbar, 4, IIf( upbar, 5, 0 ) ) );
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );

_SECTION_END();
Reply With Quote
  #27  
Old 14th March 2008, 06:04 PM
Member
 
Join Date: May 2006
Posts: 478
Appreciation: 36
Ajax is on a distinguished road
Default Re: Need Help with this AFL

Dear Ashutosh

Worked with Pivot afl.
But its erratic. SOmetimes works,
Mostly stops analysis after 3-4 scrips.
On daily mode not much success

Ajax
Reply With Quote
  #28  
Old 14th March 2008, 06:05 PM
Member
 
Join Date: Jan 2007
Posts: 78
Appreciation: 20
ashutosh.krsrivastava is on a distinguished road
Default Re: Need Help with this AFL

Hi ramesh,
use
Code:
Plot(Ref( ValueWhen( Ref( Sd2 != 0, 1 ) OR lastbar, swinglevel ,  0 ), -1 ),"Gann Swing", gannClr, 512+1024);
	PlotOHLC(O, H, L, C, "bars", barClr, styleNoTitle | styleBar | GetPriceStyle() );
in place of:
Code:
/* Gann Swing chart drawn here */
Graph1 = Ref( ValueWhen( Ref( Sd2 != 0, 1 ) OR lastbar, swinglevel , 0 ), -1 );
Graph1Style = 512+1024;
GraphXSpace = 10;
Reply With Quote
  #29  
Old 14th March 2008, 06:07 PM
Member
 
Join Date: Jan 2007
Posts: 78
Appreciation: 20
ashutosh.krsrivastava is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by Ajax View Post
Dear Ashutosh

Worked with Pivot afl.
But its erratic. SOmetimes works,
Mostly stops analysis after 3-4 scrips.
On daily mode not much success

Ajax
Hi Ajax,
will check it. Just to point to you that the formula uses forward reference. Check:
Formula Editor -> Tools -> Check;
regards
ashutosh
Reply With Quote
  #30  
Old 15th March 2008, 11:06 AM
Member
 
Join Date: Mar 2007
Posts: 65
Appreciation: 20
ramash is on a distinguished road
Default Re: Need Help with this AFL

Quote:
Originally Posted by ashutosh.krsrivastava View Post
Hi ramesh,
use
Code:
Plot(Ref( ValueWhen( Ref( Sd2 != 0, 1 ) OR lastbar, swinglevel ,  0 ), -1 ),"Gann Swing", gannClr, 512+1024);
	PlotOHLC(O, H, L, C, "bars", barClr, styleNoTitle | styleBar | GetPriceStyle() );
in place of:
Code:
/* Gann Swing chart drawn here */
Graph1 = Ref( ValueWhen( Ref( Sd2 != 0, 1 ) OR lastbar, swinglevel , 0 ), -1 );
Graph1Style = 512+1024;
GraphXSpace = 10;
hi ahutosh

thanks for your help. it works fine for me now.

Mean while i developed another system with the following conds.

Buy when

RSI( 14 ) < 50, MACD( 12, 26 ) > 0 and
MA( Close , 4 ) > MA( Close , 17 ) and
MA( Close , 17 ) > EMA( Close , 34 ) and
EMA( Close , 34 ) > MA( Close , 50 ); and vice versa for sell.

i developed the afl and am attaching the same with the chart so far i get.
i have taken only buy1 and sell3 to print as i don't know how should i do this.

i need a buy only when all the ma's cond get satisfied or sell only when all fails. kindly see to this and help me ashutosh. hope am not bugging u much.

ramash
Attached Files
File Type: txt emas.txt (1.2 KB, 26 views)
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


All times are GMT +5.5. The time now is 01:00 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