NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript File Sharing > NinjaScript File Sharing Discussion

NinjaScript File Sharing Discussion Discussion for shared NinjaScript files.

Reply
 
Thread Tools Display Modes
Old 10-30-2007, 06:32 AM   #1
JC_Fernandes
Junior Member
 
Join Date: Oct 2007
Location: UK
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default Ichimoku Kinko Yuo

As an ilustration of what I did, using region colouring (please see http://www.ninjatrader-support.com/v...8759#post18759) I built what must be my first or second NT indicator - the Ichimoku Kinko Yuo (please see http://www.kumotrader.com/ichimoku_w...itle=Main_Page for details).

Because the indicator is not that simple, and I could not get code samples anywhere, I hope that my interpretation is correct.
Feedback is very much appreciated.

This indicator deserves some attention, because, from what I read, this is all you need to make trading decisions.
You just need the right conditions/tests.

Thanks and have fun with it,

JC
Attached Files
File Type: zip Ichimoku.zip (6.7 KB, 372 views)
JC_Fernandes is offline  
Reply With Quote
Old 10-30-2007, 06:45 AM   #2
Rollins
Senior Member
 
Join Date: Sep 2007
Posts: 201
Thanks: 0
Thanked 0 times in 0 posts
Default

Nice work JC, thanks for sharing.
Rollins is offline  
Reply With Quote
Old 10-30-2007, 08:40 AM   #3
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 665
Thanks: 36
Thanked 11 times in 8 posts
Default The name Ichimoku Kinko Hyo translates to "Equilibrium chart at a glance"

Looks interesting.

In trying to figure out what an Inchmoku was all about, I googled some of the names found in the indicator, and found the following definitions: tenkan-sen, kijun-sen, chikou-span, senkou-span-A, senkou-span-B.

The full description in the article referred to by JC is much more complete, however.
Last edited by KBJ; 10-30-2007 at 08:44 AM. Reason: Add title
KBJ is offline  
Reply With Quote
Old 10-30-2007, 10:45 AM   #4
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 665
Thanks: 36
Thanked 11 times in 8 posts
Default

Commented and cleaned up the code. I think you'll find it much easier to understand.
Attached Files
File Type: zip Ichimoku.zip (7.2 KB, 522 views)
Last edited by KBJ; 10-31-2007 at 06:35 AM. Reason: Updated sources with fix to ChikouSpan plot
KBJ is offline  
Reply With Quote
Old 10-30-2007, 11:14 AM   #5
JC_Fernandes
Junior Member
 
Join Date: Oct 2007
Location: UK
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks KBJ,
I don't think I'm any good at C#/NT, really.
But I do get lots of fun trying!

JC
JC_Fernandes is offline  
Reply With Quote
Old 10-30-2007, 12:15 PM   #6
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 665
Thanks: 36
Thanked 11 times in 8 posts
Default

I may have a slight advantage with 30+ programming experience in other languages, so don't feel bad.

What you did worked and that is a good first step.
KBJ is offline  
Reply With Quote
Old 10-30-2007, 09:33 PM   #7
yimbot
Member
 
Join Date: Jun 2006
Location: , , Australia
Posts: 69
Thanks: 0
Thanked 2 times in 2 posts
Default

Hi JC,

Just been having a look at this indicator and reading the website you suggest which is very informative. It looks to me though that your Chikou-span line is sitting 26 bars after the price, where it should be sitting 26 bars before the price.
yimbot is offline  
Reply With Quote
Old 10-30-2007, 09:33 PM   #8
rt-trader
Senior Member
 
Join Date: Jan 2007
Location: , ,
Posts: 253
Thanks: 1
Thanked 3 times in 1 post
Default

Thanks to both JC and KBJ for posting this indicator - it is intriguing.

In an attempt to better understand its application I have been googling away and as a result I have a couple of questions.

1. In every definition I have found for Chikou Span it is described as the current closing price shifterd backwards 26 periods. However as best I can see from the indicator as presented it plots the close from 26 periods ago for the current bar, which seems to be a very different look. So my question is, which is correct?

2. In a similiar vein the Senkou Span A & B are shifted forward 26 periods and in the charts shown in the link below are shown appearing 'in front' of price. So - question 2 is - Is that how the indicator is actually implemented?

Thanks

http://www.kumotrader.com/ichimoku_w...nts#Tenkan_Sen
rt-trader is offline  
Reply With Quote
Old 10-31-2007, 02:43 AM   #9
JC_Fernandes
Junior Member
 
Join Date: Oct 2007
Location: UK
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

rt-trader, yimbot,

you are very likely correct.

I'll review the implementation of this indicator.
As I said in my original post, this indicator is a bit less trivial than your average indicator, so.... thanks for pointing that out for me.

After this what I intend to do is, of course, build a profitable fully "automated" strategy around it, and post it here, of course, although the KumoTrader website does not seem to agree that this is possible. But, without trying.....

JC
JC_Fernandes is offline  
Reply With Quote
Old 10-31-2007, 03:51 AM   #10
JC_Fernandes
Junior Member
 
Join Date: Oct 2007
Location: UK
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

KBJ,

I am getting an error when importing your version of the Ichimoku ("Import failed. There are NinjaScript files in the imported NinjaScript Archive File that have programming errors. These errors must be resolved before you can import the NinjaScript Archive File.")
Any idea why this is happening?

rt-trader, yimbot, and all others following this thread,

it does seem that my code is not correct, exactly because of what you said. It's easy to fix the ChikouSpan - using my old code (and until I can use KBJ's version) you should have something like
...
cs = Close[0]; <- new line
if (CurrentBar >= Period2 )
ks = ( MAX(High,Period2)[0] + MIN(Low,Period2)[0] ) / 2;
else
ks = Median[0];

and further down... instead of
ChikouSpan.Set(cs);
it should be
if (CurrentBar >= Period2 )
ChikouSpan.Set(Period2,cs);

Now, I'm still looking at the Senkou Spans, and there is a similar problem, but a lot bigger one (for me) :
ChikouSpan.Set(Period2,cs); means add the value of cs to the ChikouSpan DataSeries Period2 bars ago - my problem now is how to do the opposite with the Senkou Spans, given that I should have values in their DataSeries in the future, something like
SenkouSpanA.Set(-Period3,sa);
but, "obviously" this cannot be done. Also, according to the documentation any DataSeries "always contains the same number of elements as bars in a chart." which seems to imply that I cannot have n bars of prices + Period3 values for the Senkou Spans. Unless I can just shift, or offset the values of one DataSeries relative to the prices one.
Which still one not be enough because more bars are indeed needed ahead of the last price available.

So, because I'm fairly new to the NinjaScript language, I'm still trying to get to know its possibilities better before I get to a simple and efficient solution.

In the meantime, if the answer is obvious to you, please share it with us.

JC
JC_Fernandes is offline  
Reply With Quote
Old 10-31-2007, 06:33 AM   #11
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 665
Thanks: 36
Thanked 11 times in 8 posts
Default

I have revised the code to plot the ChikouSpan 26 periods in the past, and updated the source found in my original post.
KBJ is offline  
Reply With Quote
Old 10-31-2007, 08:38 AM   #12
JC_Fernandes
Junior Member
 
Join Date: Oct 2007
Location: UK
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks KBJ,

in the meantime I found the solution to my problem with importing your code: I had created another indicator, based on the Ichimoku, that had KinjunSen, instead of Kijunsen - so, when NT tried to import it, and re-compiled dependencies this would not work - but sme detective work fixed it... as always.

I am still searching for a solution for the Senkou spans - how to set a value in a DataSeries x bars ahead of the current one.

Regards,

JC
JC
JC_Fernandes is offline  
Reply With Quote
Old 10-31-2007, 06:12 PM   #13
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 665
Thanks: 36
Thanked 11 times in 8 posts
Default Back to the Future

JC,

The SenkouSpanA & senkouSpanB are being set correctly.

When the Ichimoku description talks about setting a value in the future, obviously that's not possible. But you can take a value from the past and use it to set the present value, and that's what the indicator does with this code:

Code:
SenkouSpanA.Set( ( MAX(High,PeriodFast)[PeriodMedium] + MIN(Low,PeriodFast)[PeriodMedium]
                 + MAX(High,PeriodMedium)[PeriodMedium] + MIN(Low,PeriodMedium)[PeriodMedium] ) / 4 );
The expression "[PeriodMedium]" means to take the value from PeriodMedium bars back, and that value is set as the current value for the SenkouSpanA. When looking at it from the viewpoint of when the MAX and MIN values were found, the plot is in the future relative to that point.

I hope this explains it satisfactorily.

KBJ
KBJ is offline  
Reply With Quote
Old 10-31-2007, 06:37 PM   #14
rt-trader
Senior Member
 
Join Date: Jan 2007
Location: , ,
Posts: 253
Thanks: 1
Thanked 3 times in 1 post
Default

Thanks KBJ,

Both for the explanation and the correction to the ChikouSpan offset.... it now appears to be plotting as it should which is great.

I have added the three lines of code below just under ChikouSpan.Set so lines are drawn from the current close back to the offset set bar and the last ChikouSpan plot. Also, the distance between the two appears on the chart. It allows for a quick visual on the underlying 'strength' of the ChikouSpan.


DrawLine("L1", 26, Close[26], 26, Close[0], Color.Blue, DashStyle.Dot, 2);

DrawLine("L2", 26, Close[0], 0, Close[0], Color.Blue, DashStyle.Dot, 2);

DrawText("T1", (Close[0] - Close[26]).ToString(), 26, Close[0] - (TickSize * 2), Color.Cyan);
rt-trader is offline  
Reply With Quote
Old 11-01-2007, 02:32 AM   #15
JC_Fernandes
Junior Member
 
Join Date: Oct 2007
Location: UK
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks everyone for all your contributions and clarifications.

I think that my quest regarding the SenkouSpans was also driven by the fact that I had seen several Ichimoku Kenko Hyo charts showing the Cloud depicted several bars ahead of the last available price, as if "predicting" future levels of support and/or resistance, thereby allowing for possible preemptive actions, depending on the strategies.

In the background I will sitll toy with this (I thought about using Displacement=... but this applies to the whole indicator, unless...)

Anyway, as it is, it's already a very good starting point
If and when I come up with a consistently profitable strategy using this indicator I will post it here (It it works for me, and I prefer intraday FX, it might work for you all too).

This is indeed a great community of users,

JC
JC_Fernandes is offline  
Reply With Quote
Reply

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

Forum Jump


All times are GMT -6. The time now is 04:47 AM.