Ichimoku span shift

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Ichimoku span shift

Postby jsi@jp » Tue Jul 27, 2010 10:26 am

Could anyone answer the request :?:

<Outline>
(1) "SL" to select true or false.
(2) "TL" to select true or false.
(3) "CS" to select true or false & Shift(Select to Period).
(4) "SA"&"SB" to Shift(Select to Period).
(5) "SA"&"SB" to short & long Falling - Red.
(6) "SA" "SB" to crosses over Signal.
(7) "SA" "SB" to bSource.close Signal.

Thank you very much in advance.
Attachments
Shift_ICH.png
Ichimoku span shift
jsi@jp
 
Posts: 26
Joined: Mon May 31, 2010 11:39 pm

Re: Ichimoku span shift

Postby jsi@jp » Thu Jul 29, 2010 7:52 am

This is almost the same "mq4" version as hope.

Code: Select all
//+------------------------------------------------------------------+
//|                                                           Ichimoku.mq4  |
//|              Copyright ゥ 2004, MetaQuotes Software Corp. |
//|                                      http://www.metaquotes.net  |
//+------------------------------------------------------------------+
#property copyright "Copyright ゥ 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 LightSeaGreen
#property indicator_color3 MediumBlue
#property indicator_color4 Maroon
#property indicator_color5 White
#property indicator_color6 SandyBrown
#property indicator_color7 Thistle
//---- input parameters
extern int Tenkan=9;
extern int Kijun=26;
extern int Senkou=52;
extern int SS_Shift=0;
extern int CS_Shift=0;

//---- buffers
double Tenkan_Buffer[];
double Kijun_Buffer[];
double SpanA_Buffer[];
double SpanB_Buffer[];
double ChinkouZen_Buffer[];
double Chinkou_Buffer[];
double SpanA2_Buffer[];
double SpanB2_Buffer[];
//----
int a_begin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//----
   SetIndexStyle(0,DRAW_LINE );
   SetIndexBuffer(0,Tenkan_Buffer);
   SetIndexDrawBegin(0,Tenkan-1);
   SetIndexLabel(0,"TenkanSen "+Tenkan+"");
//----
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Kijun_Buffer);
   SetIndexDrawBegin(1,Kijun-1);
   SetIndexLabel(1,"KijunSen"+Kijun+"");
//----
//----
   a_begin=Kijun; if(a_begin<Tenkan) a_begin=Tenkan;
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
   SetIndexBuffer(2,SpanA_Buffer);
   SetIndexDrawBegin(2,Kijun+a_begin-1);
   SetIndexShift(2,Kijun -SS_Shift);
   SetIndexLabel(2,"SenkouSpanA,Shift"+SS_Shift+"");
   SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(5,SpanA2_Buffer);
   SetIndexDrawBegin(5,Kijun+a_begin-1);
   SetIndexShift(5,Kijun -SS_Shift);
   SetIndexLabel(5,"SenkouSpanA,Shift"+SS_Shift+"");
//----
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
   SetIndexBuffer(3,SpanB_Buffer);
   SetIndexDrawBegin(3,Kijun+Senkou-1);
   SetIndexShift(3,Kijun -SS_Shift);
   SetIndexLabel(3,"SenkouSpanB,Shift"+SS_Shift+"");
   SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(6,SpanB2_Buffer);
   SetIndexDrawBegin(6,Kijun+Senkou-1);
   SetIndexShift(6,Kijun -SS_Shift);
   SetIndexLabel(6,"SenkouSpanB,Shift"+SS_Shift+"");
//----
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,Chinkou_Buffer);
   SetIndexShift(4,-Kijun +CS_Shift);
 //     SetIndexShift(3,-Kijun +SpanShift);
   SetIndexLabel(4,"ChinkouSpan, Shift"+CS_Shift+"");
//----


   return(0);
  }
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k;
   int    counted_bars=IndicatorCounted();
   double high,low,price;
//----
   if(Bars<=Tenkan || Bars<=Kijun || Bars<=Senkou) return(0);
//---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=Tenkan;i++)    Tenkan_Buffer[Bars-i]=0;
      for(i=1;i<=Kijun;i++)     Kijun_Buffer[Bars-i]=0;
      for(i=1;i<=a_begin;i++) { SpanA_Buffer[Bars-i]=0; SpanA2_Buffer[Bars-i]=0; }
      for(i=1;i<=Senkou;i++)  { SpanB_Buffer[Bars-i]=0; SpanB2_Buffer[Bars-i]=0; }
     }
//---- Tenkan Sen
   i=Bars-Tenkan;
   if(counted_bars>Tenkan) i=Bars-counted_bars-1;
   while(i>=0)
     {
      high=High[i]; low=Low[i]; k=i-1+Tenkan;
      while(k>=i)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
        }
      Tenkan_Buffer[i]=(high+low)/2;
      i--;
     }
//---- Kijun Sen
   i=Bars-Kijun;
   if(counted_bars>Kijun) i=Bars-counted_bars-1;
   while(i>=0)
     {
      high=High[i]; low=Low[i]; k=i-1+Kijun;
      while(k>=i)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
        }
      Kijun_Buffer[i]=(high+low)/2;
      i--;
     }
//---- Senkou Span A
   i=Bars-a_begin+1;
   if(counted_bars>a_begin-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      price=(Kijun_Buffer[i]+Tenkan_Buffer[i])/2;
      SpanA_Buffer[i]=price;
      SpanA2_Buffer[i]=price;
      i--;
     }
//---- Senkou Span B
   i=Bars-Senkou;
   if(counted_bars>Senkou) i=Bars-counted_bars-1;
   while(i>=0)
     {
      high=High[i]; low=Low[i]; k=i-1+Senkou;
      while(k>=i)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
        }
      price=(high+low)/2;
      SpanB_Buffer[i]=price;
      SpanB2_Buffer[i]=price;
      i--;
     }
//---- ChinkouZenSpan
   i=Bars-1;
   if(counted_bars>1) i=Bars-counted_bars-1;
   while(i>=0) { ChinkouZen_Buffer[i]=Close[i]; i--; }

//---- Chinkou Span
   i=Bars-1;
   if(counted_bars>1) i=Bars-counted_bars-1;
   while(i>=0) { Chinkou_Buffer[i]=Close[i]; i--; }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Is it difficult in the "lua" version :?: :?:
jsi@jp
 
Posts: 26
Joined: Mon May 31, 2010 11:39 pm

Ichimoku span shift

Postby KazyFreenna » Mon Aug 02, 2010 1:41 am

I was wondering if you knew how to put this into a "span" code, seeing as it doesnt work like this...
KazyFreenna
 
Posts: 6
Joined: Sat Jul 17, 2010 5:31 am
Location: Denmark

Re: Ichimoku span shift

Postby Nikolay.Gekht » Mon Aug 16, 2010 2:35 pm

Sorry for delay. Could you please check this version of Ichimoku.

The following is changed against the default implementations:
a) The cloud is colored in different colors depending on which Span is above.
b) The Span and Chinkou shift parameters are added
c) The markers are added at the points where spans are crossed and when close price crosses one of spans.

ich1.png


download:
ich1.lua
(7.78 KiB) Downloaded 855 times


I don't want to publish it officially before the production release. For the production release I'll also add new features such as line styles into this indicator.
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Ichimoku span shift

Postby jsi@jp » Tue Aug 17, 2010 6:10 am

Thank you so much for your time.

Can a (1),(2)&(3) be done ?
(1) "kijyun" to select true or false.
(2) "Tenkan" to select true or false.
(3) "Chikou" to select true or false.

For the production release I'll also add new features such as line styles into this indicator.

That's going to be great :!:

jsi@jp
jsi@jp
 
Posts: 26
Joined: Mon May 31, 2010 11:39 pm

Re: Ichimoku span shift

Postby Nikolay.Gekht » Tue Aug 17, 2010 11:54 am

Updated version:
1) Tenkan, Kijun and Chinkou lines can be switched off (1, 2, 3 of the outline)
2) Fixed problem with detecting signal when prices crosses Span A
3) Signal added

Notes about signal:
a) Do not forget that signal appears one bar after the actual event (i.e. bar checked when it is just closed).
b) Span cross is signaled for the already closed bar, not for the bar in future which corresponds to the currently tested bar.

ich1.lua
(9.27 KiB) Downloaded 808 times

ich1_signal.lua
(3.92 KiB) Downloaded 825 times


Didn't test it much, so, please write all bugs/ideas/recommendations here.
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Ichimoku span shift

Postby jsi@jp » Wed Aug 18, 2010 6:48 am

please write all bugs/ideas/recommendations here.

Thank you for your concern.
Please add true and false to "Close price cross", for the "ich1" and "ich1_signal".

I rest my case.
jsi@jp
jsi@jp
 
Posts: 26
Joined: Mon May 31, 2010 11:39 pm

Re: Ichimoku span shift

Postby Nikolay.Gekht » Wed Aug 18, 2010 11:55 am

Now signals for span cross and for close cross are switched on/off separately. You can control any of them.

ich1.lua
(9.67 KiB) Downloaded 826 times

ich1_signal.lua
(4.38 KiB) Downloaded 803 times
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Ichimoku span shift

Postby Nikolay.Gekht » Wed Aug 18, 2010 11:56 am

I'll put this version updated for new TS in a week, together with the release.
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 10 guests