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

Please explain Rising () on 3 minute chart

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

    Please explain Rising () on 3 minute chart

    I am trying to determine when the SMA is rising. I am using the following code :

    if (Rising(SMA(50)))
    {

    Most of the time it is correct however every once in awhile for one bar it gives an incorrect signal.
    I am using a 3 minute chart. When I use Visual Studio I notice that the code is being run at three time per bar. The first time the SMA 50 value match what is on the chart. The second time the SMA 50 value is changed. Both have the time stamp of 1330. Could you please explain why this is happening?

    Also here is my Initialize function where I set CalculateOnBarClose:

    protected override void Initialize()
    {
    // Add a 15 minute Bars object to the strategy
    Add(PeriodType.Minute, 15);

    //Add(Stochastics(3, 5, 2));

    CalculateOnBarClose = true;


    //EntryHandling = EntryHadling.UniqueEntries;
    }

    Values the first time:
    Rising(smav50) false
    Mom_Value 54.2986425339362
    Past_Mom_K 40.196078431372108
    ToTime(Time[0]) 133000

    Values the second time:
    Rising(smav50) true
    Mom_Value 29.411764705882362
    Past_Mom_K 54.2986425339362
    ToTime(Time[0]) 133000

    Values the third time:
    Rising(smav50) false bool
    Mom_Value 65.384615384614932 double
    Past_Mom_K 29.411764705882362 double
    ToTime(Time[0]) 133300 int

    Value the fourth time but notice the time changed:

    Rising(smav50) false bool
    Mom_Value 65.384615384614932 double
    Past_Mom_K 65.384615384614932 double
    ToTime(Time[0]) 133600 int

    Could you please explain why this is happening? Is it running 3 times because this is a 3 minute chart? At least at the 1330 bar the 1st and 3rd values matches the SMA 50 on the chart with is down. The 2nd time does not match the SMA 50 on the chart.
    I do not want to assume I can disregard the 2nd time value.

    I have also attached the chart. Notice the green arrow.

    Thanks advance you for any help
    Attached Files

    #2
    Hello Wizard111,

    Welcome to the forums and thank you for your inquiry.

    Without the full code I am only left to speculate at the output received.

    With the information given, I see that you have a multi-series NinjaScript. If you are not using BarsInProgress checks in your code, along with minding the BarsArray used for input to your strategy's indicators, or using Times, Closes, etc. you can see some possibly unintended results.

    For example, on the close of the 15 minute bar, you will have an OnBarUpdate() iteration for that data series, and if your primary data series closes at the time, you will get another iteration for that data series.

    I would advise to use prints for Times[][] and CurrentBars[] while debugging, and I would advise to make sure you are using the right BarsArray for your strategy indicators as well as appropriate logic to limit your strategy to iterate on certain BarsInProgress'.

    All of these items can be referenced in the Multi Series NinjaScript documentation which is an important read for building any Multi Series NinjaScript. This information as publicly available, and I will provide a link below.

    Multi Series NinjaScripts (Important) - https://ninjatrader.com/support/help...nstruments.htm

    Please reach back if this information does not help resolve your inquiry.
    JimNinjaTrader Customer Service

    Comment


      #3
      I have commented out the add statement and this resolved my issue. I will do more research on the Multi Series NinjaScripts.

      Thanks again

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      10 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,235 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      3 views
      0 likes
      Last Post thread
      by thread
       
      Started by jclose, Yesterday, 09:37 PM
      0 responses
      8 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,415 views
      0 likes
      Last Post Traderontheroad  
      Working...
      X