Traderji.com - Discussion forum for Stocks Commodities & Forex

HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise Man)

Discuss HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise Man) at the AmiBroker within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Hi, I am trying to plot arrows based on Bill William's Third wise man. I ...


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

Notices


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #1  
Old 16th July 2008, 09:51 AM
Member
 
Join Date: Jul 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
lovehuman is on a distinguished road
Reputation: 20
Default HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise Man)

Hi,

I am trying to plot arrows based on Bill William's Third wise man. I am looking for five price bars at a time and comparing High values. If the middle high is higher than previous two highs and next two highs, I want to plot up Arrow symbol. However with the following code, I end up plotting uparrow on every bar (even when value of tmp is false). What am I doing wrong here?

for( i = 3; i < (BarCount-2); i++ )
{
tmp = (High[i] > High[i-1]) AND (High[i-1] > High[i-2]) AND (High[i] > High[i+1]) AND (High[i+1] > High[i+2]);
//_TRACE("tmp : " + tmp);
PlotShapes( IIf( tmp, shapeUpArrow, shapeNone ), colorGreen,0, H,10 );
}
Reply With Quote
  #2  
Old 16th July 2008, 03:22 PM
Member
 
Join Date: Jun 2007
Posts: 138
Thanks: 0
Thanked 4 Times in 3 Posts
THETRADER is on a distinguished road
Reputation: 30
Default Re: HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise M

OHLC are all arrays. You dont need to, and, should not use it as array. Just try the following :

tmp = (High > Ref(High,-1)) AND (High > Ref(High,-2)) AND (High > Ref(High,1)) AND (High > Ref(High,2));
PlotShapes( IIf( tmp, shapeUpArrow, shapeNone ), colorGreen,0, H,10 );
Reply With Quote
  #3  
Old 18th July 2008, 01:14 AM
Member
 
Join Date: Jul 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
lovehuman is on a distinguished road
Reputation: 20
Default Re: HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise M

Quote:
Originally Posted by THETRADER View Post
OHLC are all arrays. You dont need to, and, should not use it as array. Just try the following :

tmp = (High > Ref(High,-1)) AND (High > Ref(High,-2)) AND (High > Ref(High,1)) AND (High > Ref(High,2));
PlotShapes( IIf( tmp, shapeUpArrow, shapeNone ), colorGreen,0, H,10 );
Thanks a lot "TheTrader". This resolved the issue. Thanks for all your help. I was banging my head from last one week on this

Once again, thank you for helping me!
Reply With Quote
  #4  
Old 18th July 2008, 02:01 PM
Member
 
Join Date: Nov 2006
Posts: 1,425
Thanks: 7
Thanked 8 Times in 6 Posts
kkseal will become famous soon enough
Reputation: 64
Default Re: HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise M

That still doesn't explain why the original code was not working. Think the for loop should have started with i=2, but is that the reason?
Reply With Quote
  #5  
Old 18th July 2008, 05:36 PM
aad aad is offline
Member
 
Join Date: Jul 2006
Posts: 244
Thanks: 6
Thanked 22 Times in 6 Posts
aad is on a distinguished road
Reputation: 45
Default Re: HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise M

Quote:
Originally Posted by kkseal View Post
That still doesn't explain why the original code was not working. Think the for loop should have started with i=2, but is that the reason?
for loop can start with i=2 but the correct code is

_SECTION_BEGIN("William's Third Wise Man");

for( i = 3; i < (BarCount-2); i++ )
{
tmp[i] = (High[i] > High[i-1]) AND (High[i-1] > High[i-2]) AND (High[i] > High[i+1]) AND (High[i+1] > High[i+2]);
}
PlotShapes( IIf( tmp, shapeUpArrow, shapeNone ), colorGreen,0, H,10 );

_SECTION_END();

We need to store value of tmp in an array corresponding to each value of i when we use for loop. Once that is done, we then use PlotShapes() function only once (using capabilities of array in Amibroker).

Best regards,

Abhay
Reply With Quote
  #6  
Old 18th July 2008, 05:54 PM
Member
 
Join Date: Nov 2006
Posts: 1,425
Thanks: 7
Thanked 8 Times in 6 Posts
kkseal will become famous soon enough
Reputation: 64
Default Re: HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise M

Quote:
Originally Posted by aad View Post
for loop can start with i=2 but the correct code is

_SECTION_BEGIN("William's Third Wise Man");

for( i = 3; i < (BarCount-2); i++ )
{
tmp[i] = (High[i] > High[i-1]) AND (High[i-1] > High[i-2]) AND (High[i] > High[i+1]) AND (High[i+1] > High[i+2]);
}
PlotShapes( IIf( tmp, shapeUpArrow, shapeNone ), colorGreen,0, H,10 );

_SECTION_END();

We need to store value of tmp in an array corresponding to each value of i when we use for loop. Once that is done, we then use PlotShapes() function only once (using capabilities of array in Amibroker).

Best regards,

Abhay
Thanks a lot. I too felt 'tmp' was being treated as an array rather than a variable. (Moreover IIF expects an array rather than a variable though it works fine with the reserved ones like 'Buy','Sell').

But shouldn't we be using tmp[i-3] to store the array values correctly in the tmp array?

Or maybe we should simply use IF-ELSE in the original code rather than IIF.
Regards

Last edited by kkseal; 18th July 2008 at 06:01 PM.
Reply With Quote
  #7  
Old 18th July 2008, 06:38 PM
aad aad is offline
Member
 
Join Date: Jul 2006
Posts: 244
Thanks: 6
Thanked 22 Times in 6 Posts
aad is on a distinguished road
Reputation: 45
Default Re: HELP NEEDED: What's wrong with the PlotShapes in this AFL (William's Third wise M

Quote:
Originally Posted by kkseal View Post
But shouldn't we be using tmp[i-3] to store the array values correctly in the tmp array?
No need. Corresponding to the value i, you will have to store high[i] and tmp[i] in same column only. If you store at tmp[i-3] then you are asking Amibroker to store tmp[i-3] in the column of high[i], which will give wrong results i.e. when the condition for tmp returns 'true', it will be shown at 3 bars prior to actual bar...

Quote:
Or maybe we should simply use IF-ELSE in the original code rather than IIF.
Regards
As you know very well, IIF will be faster than IF-ELSE, although both will function the same.

Regards,

Abhay
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 08:34 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