Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Modified Ichimoku - Please help me to translate this thinkscript to Ninjatrader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Modified Ichimoku - Please help me to translate this thinkscript to Ninjatrader

    Hello Everyone, I'm moving from ToS to NinjaTrader in search of more flexibility and automated trading... I have a Modified Ichimoku Indicator that works wonderfully well on ToS. Could any of the NinjaScript masters help me to translate it to NinjaTrader?

    Here's the code, and thanks in advance...

    ps. Please note that TENKAN and KINJUN are similar to original Ichimoku math, but the CLOUD - span A and Span B, are different, and THE CHIKOU SPAN, WHICH IS THE MOST IMPORTANT TO ME FOR THIS PARTICULAR STRATEGY, is a Moving Linear Regression (linReg on NinjaScript) of the future fast eight Bars (-nA) and nB...

    If more info is needed, I'll be glad to provide it.


    # Adaptation of Ichimoku Strategy
    # Mobius
    # Revised Tenkan and Kijun
    # V01.12.2013

    input nA = 8;
    input nB = 21;

    #math
    def Tenkan = (Highest(high, nA) + Lowest(low, nA)) / 2;
    def Kijun = (Highest(high, nB) + Lowest(low, nB)) / 2;
    def "Span A" = (Tenkan[nA] + Kijun[nA]) / 2;
    def "Span B" = (Highest(high[nA], nB) + Lowest(low[nA], nB)) / 2;
    plot Chikou = Inertia(close[-nA], nB);

    # Color Config
    #"Span A".SetDefaultColor(Color.PLUM);
    #"Span B".SetDefaultColor(Color.YELLOW);
    Chikou.SetDefaultColor(Color.WHITE);
    DefineGlobalColor("Bullish", Color.YELLOW);
    DefineGlobalColor("Bearish", Color.RED);
    #AddCloud("Span A", "Span B", GlobalColor("Bullish"), GlobalColor("Bearish"));

    ##Arrows on Chikou Crossover
    # changed from crosses above to >
    plot ArrowUp = Chikou crosses above Max("Span A", "Span B");
    ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLE AN_ARROW_UP);
    ArrowUp.SetLineWeight(1);
    ArrowUp.SetDefaultColor(Color.WHITE);
    # changed from crosses below to <
    plot ArrowDn = Chikou crosses below Min("Span A", "Span B");
    ArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLE AN_ARROW_DOWN);
    ArrowDn.SetLineWeight(1);
    ArrowDn.SetDefaultColor(Color.YELLOW);

    #2
    Hello rmnjtrdr,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    You may find the indicator you are trying to build in the file sharing section: http://www.ninjatrader.com/support/f...splay.php?f=37

    Comment


      #3
      Hello NinjaTrader_PatrickH,

      Thanks a lot for your quick reply. I've checked the link you suggested. I've revised the code for all the ichimoku indicators in there, and there's still nothing similar to this one I have. It's a modified ichimoku version, that works pretty well, thus the reason why I'm insisting in having it on NinjaTrader...

      But Maybe I could simplify things: I just need help with five crucial lines of code:

      input nA = 8;
      input nB = 21;

      def Tenkan = (Highest(high, nA) + Lowest(low, nA)) / 2;
      def Kijun = (Highest(high, nB) + Lowest(low, nB)) / 2;
      plot "Span A" = (Tenkan[nA] + Kijun[nA]) / 2;
      plot "Span B" = (Highest(high[nA], nB) + Lowest(low[nA], nB)) / 2;
      plot Chikou = Inertia(close[-nA], nB);


      I don't know how to do these in NinjaScript. I've tried for a couple of hours, but the language is so much more robust and complex than Thinkscript that I couldn't get it to compile.

      BTW, Inertia, in the above code, is a LInear Regression Line in Thinkscript. I've checked the math, and it seems to be the same, for that line.

      Thanks again for any help!
      Attached Files
      Last edited by rmnjtrdr; 10-13-2014, 06:58 AM. Reason: adding a few more details

      Comment


        #4
        Hello ,

        This is my understanding of the code. Keep in mind I am not familiar with thinkscript and we do not provide conversion services from one language to NinjaScript:
        Code:
                #region Variables
        		private int nA = 8;
        		private int nB = 21;
        		private double tenkan;
        		private double kijun;
                #endregion		
        
                protected override void Initialize()
                {
        			Add(new Plot(Color.Red, "SpanA"));
        			Add(new Plot(Color.Blue, "SpanB"));
        			Add(new Plot(Color.Black, "Chikou"));
                }
        
                protected override void OnBarUpdate()
                {
        			if(CurrentBar <= nA || CurrentBar <= nB)
        				return;
        			
        			tenkan = (MAX(High, nA)[0] + MIN(Low, nA)[0])/2;
        			kijun = (MAX(High, nB)[0] + MIN(Low, nB)[0])/2;
        			
        			Values[0].Set((tenkan + kijun)/2);
        			Values[1].Set((MAX(MAX(High, nA), nB)[0] + MIN(MIN(Low, nA), nB)[0])/2);
        			Values[2].Set(LinReg(Close, nB)[0]);
        }

        Comment


          #5
          Thank you so much, Patrick, for your time. I'll try it out and post the results here.

          update: Patric, I appreciate your help. but It's not quite there yet... the chikou line is not displaced behind price by the nA period..., and the clouds don't match.

          Thanks for your time, though. I'll keep trying here. Your code helped me to understand a little bit more about the language for the plots and the math. I believe I'll get more experienced with the language as I play with it, then I should be able to fix it myself.

          thanks.
          Last edited by rmnjtrdr; 10-14-2014, 05:17 PM. Reason: updated info after testing...

          Comment


            #6
            Hey,

            Did you ever get ThinkorSwims ichimoku cloud to work on ninjatrader? i want to do the same thing. Let me know would be great if you did

            Comment


              #7
              Originally posted by rmnjtrdr View Post
              Hello Everyone, I'm moving from ToS to NinjaTrader in search of more flexibility and automated trading... I have a Modified Ichimoku Indicator that works wonderfully well on ToS. Could any of the NinjaScript masters help me to translate it to NinjaTrader?

              Here's the code, and thanks in advance...

              ps. Please note that TENKAN and KINJUN are similar to original Ichimoku math, but the CLOUD - span A and Span B, are different, and THE CHIKOU SPAN, WHICH IS THE MOST IMPORTANT TO ME FOR THIS PARTICULAR STRATEGY, is a Moving Linear Regression (linReg on NinjaScript) of the future fast eight Bars (-nA) and nB...

              If more info is needed, I'll be glad to provide it.


              # Adaptation of Ichimoku Strategy
              # Mobius
              # Revised Tenkan and Kijun
              # V01.12.2013

              input nA = 8;
              input nB = 21;

              #math
              def Tenkan = (Highest(high, nA) + Lowest(low, nA)) / 2;
              def Kijun = (Highest(high, nB) + Lowest(low, nB)) / 2;
              def "Span A" = (Tenkan[nA] + Kijun[nA]) / 2;
              def "Span B" = (Highest(high[nA], nB) + Lowest(low[nA], nB)) / 2;
              plot Chikou = Inertia(close[-nA], nB);

              # Color Config
              #"Span A".SetDefaultColor(Color.PLUM);
              #"Span B".SetDefaultColor(Color.YELLOW);
              Chikou.SetDefaultColor(Color.WHITE);
              DefineGlobalColor("Bullish", Color.YELLOW);
              DefineGlobalColor("Bearish", Color.RED);
              #AddCloud("Span A", "Span B", GlobalColor("Bullish"), GlobalColor("Bearish"));

              ##Arrows on Chikou Crossover
              # changed from crosses above to >
              plot ArrowUp = Chikou crosses above Max("Span A", "Span B");
              ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLE AN_ARROW_UP);
              ArrowUp.SetLineWeight(1);
              ArrowUp.SetDefaultColor(Color.WHITE);
              # changed from crosses below to <
              plot ArrowDn = Chikou crosses below Min("Span A", "Span B");
              ArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLE AN_ARROW_DOWN);
              ArrowDn.SetLineWeight(1);
              ArrowDn.SetDefaultColor(Color.YELLOW);
              I know i am late to the party .. I recently started trading and lost a good chunk of money because of my ignorance in cutting losses. I came across ichimoku recently and loving it so far.. But still i am not able to make good decisions about entry and exit.. I tried your script and i see it is putting some arrows when its bullish or bearish.. But it plots it way too late after the oppurtunity is gone.. Can you let me know how to use this study properly? Thanks in advance

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              5 views
              0 likes
              Last Post usazencortex  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              168 responses
              2,265 views
              0 likes
              Last Post sidlercom80  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              12 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X