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

Candlesticks indicator

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

    Candlesticks indicator

    Hi,
    I'd like to convert my indicator to plot with candlesticks (like ValueCharts). I get candlesticks but it's not correct. Explanations :

    My indicator returns a value which is a double :
    value += (bal - value) * multiplier;

    Then I try to adapt to Roonius sample :
    balance.Set(value);
    balanceOpen.Set(balance[1]);
    balanceClose.Set(balance[0]);
    balanceHigh.Set(Math.Max(balance[0], balance[1]));
    balanceLow.Set(Math.Min(balance[0], balance[1]));

    2 issues :
    - no gap as expected but I'm more concerned by the 2nd issue now
    - no tails (highs, lows)

    I tried working with value as a DataSerie but still the issues.

    Thanks for your help

    #2
    Hi sam30, thanks for your post - have you plotted the 'value' itself and checked for correct calculations? I would imagine if it doesn't change much from bar to bar you can get nonexisting highs / lows in the final plot.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes I can plot the 'value' itself and it changes a lot from bar to bar.
      For example, I can see the candlestick going up then it goes a little bit down but the high is not plotted.

      Comment


        #4
        sam30,

        Please print your balance[0] and balance[1] values to see what is happening.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,
          I added this indicator to a 5 sec chart and do :
          Print(DateTime.Now);
          Print(balance[0]);
          Print(balance[1]);
          Print("\n");


          27/03/2009 16:52:17
          -0,106418020118073
          0


          27/03/2009 16:52:18
          -0,639433666008367
          -0,106418020118073


          27/03/2009 16:52:19
          -0,803503222150815
          -0,106418020118073


          27/03/2009 16:52:20
          -0,913540910687738
          -0,106418020118073


          27/03/2009 16:52:21
          -1,42004555629196
          -0,106418020118073


          27/03/2009 16:52:22
          -1,89498834206783
          -1,42004555629196


          27/03/2009 16:52:23
          -2,19276918144464
          -1,42004555629196


          27/03/2009 16:52:24
          -2,35289905100482
          -1,42004555629196


          27/03/2009 16:52:25
          -2,49590010721449
          -1,42004555629196


          27/03/2009 16:52:26
          -2,62718827097364
          -2,49590010721449


          27/03/2009 16:52:27
          -2,74812431086779
          -2,49590010721449


          27/03/2009 16:52:28
          -2,86997169536752
          -2,49590010721449


          27/03/2009 16:52:29
          -2,99584485453025
          -2,49590010721449


          27/03/2009 16:52:30
          -3,08934616790684
          -2,49590010721449


          27/03/2009 16:52:31
          -3,18379262644932
          -3,08934616790684


          27/03/2009 16:52:32
          -3,26923661755591
          -3,08934616790684


          27/03/2009 16:52:33
          -3,3565149796701
          -3,08934616790684


          27/03/2009 16:52:34
          -3,4851042069881
          -3,08934616790684


          27/03/2009 16:52:35
          -3,67224053043476
          -3,08934616790684


          27/03/2009 16:52:36
          -3,85543678091165
          -3,08934616790684


          27/03/2009 16:52:37
          -4,03054299843485
          -3,85543678091165


          27/03/2009 16:52:38
          -4,49061494913804
          -3,85543678091165


          27/03/2009 16:52:39
          -4,57014146113935
          -3,85543678091165


          27/03/2009 16:52:40
          -4,72418112484343
          -3,85543678091165


          27/03/2009 16:52:41
          -4,91116273388816
          -4,72418112484343


          27/03/2009 16:52:42
          -5,02964418289716
          -4,72418112484343


          27/03/2009 16:52:43
          -5,08825074083849
          -4,72418112484343


          27/03/2009 16:52:44
          -5,13466313727309
          -4,72418112484343


          27/03/2009 16:52:45
          -5,16905848877486
          -4,72418112484343

          Comment


            #6
            So by 16:52:45 your balanceHigh plot should be -4,72418112484343. Please confirm/deny this.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Yes I got this high but the problem is there :

              Now I print :
              Print(DateTime.Now);
              Print("Open : " + balance[1]);
              Print("Close : " + balance[0]);
              Print("High : " + Math.Max(balance[0], balance[1]));
              Print("Low : " + Math.Min(balance[0], balance[1]));

              And I get the expected result (but not what I want), see below.
              For every new 'value', the high/low are calculated but I want to keep the high/low for the actual bar (here 5 sec).
              So I guess I have to create other DataSeries to store the highs/lows...


              27/03/2009 17:59:34
              Open : 0
              Close : -0,289466808773581
              High : 0
              Low : -0,289466808773581
              27/03/2009 17:59:35
              Open : 0
              Close : -0,804517077375203
              High : 0
              Low : -0,804517077375203
              27/03/2009 17:59:36
              Open : 0
              Close : -1,31161472749958
              High : 0
              Low : -1,31161472749958
              27/03/2009 17:59:37
              Open : -1,31161472749958
              Close : -1,80529884827445
              High : -1,31161472749958
              Low : -1,80529884827445
              27/03/2009 17:59:38
              Open : -1,31161472749958
              Close : -2,24986700476203
              High : -1,31161472749958
              Low : -2,24986700476203
              27/03/2009 17:59:39
              Open : -1,31161472749958
              Close : -2,65532121195903
              High : -1,31161472749958
              Low : -2,65532121195903
              27/03/2009 17:59:40
              Open : -1,31161472749958
              Close : -3,04226689243404
              High : -1,31161472749958
              Low : -3,04226689243404
              27/03/2009 17:59:41
              Open : -3,04226689243404
              Close : -3,41520184380888
              High : -3,04226689243404
              Low : -3,41520184380888
              27/03/2009 17:59:42
              Open : -3,04226689243404
              Close : -3,78055332292226
              High : -3,04226689243404
              Low : -3,78055332292226
              27/03/2009 17:59:43
              Open : -3,04226689243404
              Close : -4,12690030585468
              High : -3,04226689243404
              Low : -4,12690030585468
              27/03/2009 17:59:44
              Open : -3,04226689243404
              Close : -4,45591223337959
              High : -3,04226689243404
              Low : -4,45591223337959
              27/03/2009 17:59:45
              Open : -3,04226689243404
              Close : -4,76301760720382
              High : -3,04226689243404
              Low : -4,76301760720382
              27/03/2009 17:59:46
              Open : -3,04226689243404
              Close : -5,04930003595984
              High : -3,04226689243404
              Low : -5,04930003595984
              27/03/2009 17:59:47
              Open : -5,04930003595984
              Close : -5,32288400160398
              High : -5,04930003595984
              Low : -5,32288400160398
              27/03/2009 17:59:48
              Open : -5,04930003595984
              Close : -5,58086819466443
              High : -5,04930003595984
              Low : -5,58086819466443

              Comment


                #8
                sam30,

                You should not be checking balance[0] against [1] in that case. You should be checking the incoming tick against the previous stored high value. Only store a new one if the new tick is higher than the old high.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by funk10101, Today, 12:02 AM
                0 responses
                3 views
                0 likes
                Last Post funk10101  
                Started by gravdigaz6, Yesterday, 11:40 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by MarianApalaghiei, Yesterday, 10:49 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by XXtrader, Yesterday, 11:30 PM
                0 responses
                4 views
                0 likes
                Last Post XXtrader  
                Started by love2code2trade, 04-17-2024, 01:45 PM
                4 responses
                28 views
                0 likes
                Last Post love2code2trade  
                Working...
                X