indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Trading > Beginners Section

Beginners Section For those new to Trading

NordFX
Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #51 (permalink)  
Old 03-11-2017, 08:06 PM
asnavale asnavale is offline
indiTraders VIP
 
Join Date: Jun 2014
Posts: 425
Thanks: 873
Thanked 1,239 Times in 418 Posts
asnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to all
Default

Originally Posted by sr114 View Post
Code:
S1:=Sin(1*.0174532)*C;
Here 0.0174532 = Pi divided by 180 and becomes the radians.So no need to convert.

But, Uasish has used Sin(0.0174532) and it is Metastok code. So, the angle is in degrees. So, it has to be converted to radians for Ami.

In addition, You have initialised Bot =0; and then there is a for loop where you write Bot = Bot[i -1]; This is superfluous. Since you have initialised the array Bot = 0 it means all values of Bot are filled with 0. So, the for loop is not doing anything extra except wasting CPU time.

Since you have made Bot=0 for all values of i = 0 to i = BarCount-1, at i = 22, Bot is zero. So when you use it for calculating Bot[22], you will be using this value of Bot[22] which is zero but you should be using (1-1/11)*C+C. Just look at the equations and manually do the calculations till i = 22. You will know the difference. This erroneous value of Bot[22] leads to error in value of Trend[22] and all further values. So, you will end up with a different value for the Upper, Middle and Lower lines in the chart.

-Anant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to asnavale For This Useful Post:
  #52 (permalink)  
Old 03-11-2017, 08:38 PM
LifeOk's Avatar
LifeOk LifeOk is offline
Newbie
 
Join Date: Mar 2017
Posts: 4
Thanks: 10
Thanked 8 Times in 3 Posts
LifeOk is on a distinguished road
Default

Code:
Bot	= ...; //initialize bot & trend
Trend	= ...; //

for(i=1;i<BarCount;i++ )
{
Prev		= Bot[i-1];
TPrev		= Trend[i-1];

Bot[i]		= (1-1/11)*(IIf(i<21,C[i],PREV))+C[i];
Trend[i]	= (1-1/11)*(IIf(i<21,C[i],TPrev))+(1/11*(C[i]+Bot[i]-Bot[i-1]));
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 3 Users Say Thank You to LifeOk For This Useful Post:
  #53 (permalink)  
Old 03-11-2017, 11:16 PM
asnavale asnavale is offline
indiTraders VIP
 
Join Date: Jun 2014
Posts: 425
Thanks: 873
Thanked 1,239 Times in 418 Posts
asnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to all
Default

Originally Posted by LifeOk View Post
Code:
Bot	= ...; //initialize bot & trend
Trend	= ...; //

for(i=1;i<BarCount;i++ )
{
Prev		= Bot[i-1];
TPrev		= Trend[i-1];

Bot[i]		= (1-1/11)*(IIf(i<21,C[i],PREV))+C[i];
Trend[i]	= (1-1/11)*(IIf(i<21,C[i],TPrev))+(1/11*(C[i]+Bot[i]-Bot[i-1]));
}

What is the value with which you initialse Bot and Trend ?

The For loop wastes time. Just write

Code:
Prev = Ref(Bot, -1); 
TPrev = Ref(Trend, -1);
Bot = (1-1/11) * (IIf(Cum(1)< 21, C, Prev) + C;
Trend = (1-1/11)*(IIF(Cum(1) < 21, C, TPrev) + (1/11)*(C+Bot-Ref(Bot, -1));

This runs much faster.

-Anant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to asnavale For This Useful Post:
  #54 (permalink)  
Old 04-11-2017, 12:41 AM
no1lives4ever no1lives4ever is offline
Newbie
 
Join Date: Jul 2009
Posts: 3,561
Thanks: 22,078
Thanked 6,029 Times in 2,568 Posts
no1lives4ever has a reputation beyond repute
no1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond repute
Default

Originally Posted by asnavale View Post
Code:
Prev = Ref(Bot, -1); 
Bot = (1-1/11) * (IIf(Cum(1)< 21, C, Prev) + C;

This code is not the same as doing it in a for loop. this will not work the same as:

Code:
for(i=1;i<BarCount;i++ )
{
Prev		= Bot[i-1];
Bot[i]		= (1-1/11)*(IIf(i<21,C[i],PREV))+C[i];
}
-- no1lives4ever
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 4 Users Say Thank You to no1lives4ever For This Useful Post:
  #55 (permalink)  
Old 11-11-2017, 10:38 PM
uasish's Avatar
uasish uasish is offline
Super Moderator
 
Join Date: Mar 2009
Location: Kolkata,India.
Posts: 8,164
Thanks: 9,105
Thanked 15,082 Times in 5,553 Posts
uasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond repute
uasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond repute
Default

All quite in the western front
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to uasish For This Useful Post:
  #56 (permalink)  
Old 12-11-2017, 10:06 AM
asnavale asnavale is offline
indiTraders VIP
 
Join Date: Jun 2014
Posts: 425
Thanks: 873
Thanked 1,239 Times in 418 Posts
asnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to all
Default

Originally Posted by no1lives4ever View Post
This code is not the same as doing it in a for loop. this will not work the same as:

Code:
for(i=1;i<BarCount;i++ )
{
Prev		= Bot[i-1];
Bot[i]		= (1-1/11)*(IIf(i<21,C[i],PREV))+C[i];
}
-- no1lives4ever

Again, the same question. If you are using loop, then what is the value of Bot for i=0 ? Because, when you write Prev = Bot[i-1], for i=1, Prev=Bot[i-1] = Bot[0]. Since Bot is not initialised, Bot[0] is undefined. Can you clarify ?

-Anant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to asnavale For This Useful Post:
  #57 (permalink)  
Old 14-11-2017, 09:16 AM
no1lives4ever no1lives4ever is offline
Newbie
 
Join Date: Jul 2009
Posts: 3,561
Thanks: 22,078
Thanked 6,029 Times in 2,568 Posts
no1lives4ever has a reputation beyond repute
no1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond reputeno1lives4ever has a reputation beyond repute
Default

Originally Posted by asnavale View Post
Again, the same question. If you are using loop, then what is the value of Bot for i=0 ? Because, when you write Prev = Bot[i-1], for i=1, Prev=Bot[i-1] = Bot[0]. Since Bot is not initialised, Bot[0] is undefined. Can you clarify ?

-Anant

That is a function of your algorithm. In most cases you set the initial value to 0 or some other value.

Mostly for such formulae, you will need to wait for a certain number of bars before the values stabilise.

You will also want to check these links on the Amibroker website:
https://www.amibroker.com/guide/afl/...srequired.html
http://www.amibroker.com/kb/2008/07/03/quickafl/

BTW.. I just posted code here to illustrate some point. I did not post code that is expected to work.

-- no1lives4ever
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 3 Users Say Thank You to no1lives4ever For This Useful Post:
  #58 (permalink)  
Old 16-11-2017, 10:46 AM
asnavale asnavale is offline
indiTraders VIP
 
Join Date: Jun 2014
Posts: 425
Thanks: 873
Thanked 1,239 Times in 418 Posts
asnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to allasnavale is a name known to all
Default

Originally Posted by no1lives4ever View Post
That is a function of your algorithm. In most cases you set the initial value to 0 or some other value.

Mostly for such formulae, you will need to wait for a certain number of bars before the values stabilise.

You will also want to check these links on the Amibroker website:
https://www.amibroker.com/guide/afl/...srequired.html
http://www.amibroker.com/kb/2008/07/03/quickafl/

BTW.. I just posted code here to illustrate some point. I did not post code that is expected to work.

-- no1lives4ever

The initialised value of Bot and Trend has effect on the further values which depend on previous values. So, if we initialise with zero the calculated values will differ from those when intialised with Close value.

For this formula, bars required need not be specified, since formula uses Cum(21) and Ref(..., -1) functions. So, a minimum of 22 values will be needed. But by default, Ami uses 30 as bars required. So, no need to specify.

-Anant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to asnavale For This Useful Post:
  #59 (permalink)  
Old 16-11-2017, 01:46 PM
sr114's Avatar
sr114 sr114 is offline
Regulars
 
Join Date: Aug 2010
Location: INDIA
Posts: 359
Thanks: 377
Thanked 678 Times in 253 Posts
sr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nice
Default

Code:
Z =(A*B)+(C*PREV);

where PREV is previous value of Z. 
Code:
Prev As used in Metastock
Previous in "bar by bar" manner. Hence the formula is self-referencing (in mathematics it is recursive formulation) and as such can be only written using loop or using AMA Ref( Z, -1 ) would not work because it processes entire array at once and would not give you recursive effect. http://www.amibroker.com/guide/h_understandafl.html Best regards, Tomasz Janeczko amibroker.com
Ref :
HTML Code:
https://www.mail-archive.com/amibroker@yahoogroups.com/msg41704.html
2.
Code:
PREV is NOT ref(c,-1) in this example but yesterday's value of Z. Otherwise 
> PREV wouldn't be necessary im Metastock since MS has the same ref function 
> like Amibroker.
> 
> Regards,
> 
> Thomas
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 3 Users Say Thank You to sr114 For This Useful Post:
  #60 (permalink)  
Old 16-11-2017, 01:48 PM
sr114's Avatar
sr114 sr114 is offline
Regulars
 
Join Date: Aug 2010
Location: INDIA
Posts: 359
Thanks: 377
Thanked 678 Times in 253 Posts
sr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nicesr114 is just really nice
Default

http://forum.amibroker.com/t/doubt-w...erencing/835/3

also see this link

Last edited by sr114; 16-11-2017 at 01:58 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to sr114 For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Trading > Beginners Section


Thread Tools
Display Modes

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 On
Refbacks are On


NordFX

All times are GMT +5.5. The time now is 07:04 PM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2