Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about plot multiframe

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

    Question about plot multiframe

    1) I want to plot in the same indicator 2 indicator SMA
    is correct to do this or exist another good way to plot in multiframe

    Code:
        else if (State == State.Configure)
                {
                    AddDataSeries(BarsPeriodType.Minute,30);
                }
    
        protected override void OnBarUpdate()
            {
    
                if (BarsInProgress == 1)
                    test=SMA(BarsArray[1], 3)[0];
     Value[0] =test;
    2) can i choose how many series to add and the BarsPeriodType by general menu indicator?

    (see example in the pics below)



    If answer is Ok....how can i do it?

    thanks
    Last edited by turbofib; 03-10-2016, 09:21 AM.

    #2
    Hello,

    If you are asking how to plot the SMA for the Primary and the SMA for the secondary series from the same indicator, you could use something like the following:

    Code:
    protected override void OnStateChange()
    {
    	if (State == State.SetDefaults)
    	{
    		AddPlot(Brushes.Red, "Plot0");
    		AddPlot(Brushes.Red, "Plot1");
    	}
    	else if (State == State.Configure)
    	{
    		AddDataSeries(BarsPeriodType.Minute,30);
    	}
    }
    
    protected override void OnBarUpdate()
    {
    	if(CurrentBars[0] > 1 && CurrentBars[1] > 1 && BarsInProgress == 0){
    		Values[0][0] = SMA(BarsArray[0], 12)[0];	
    		Values[1][0] = SMA(BarsArray[1], 12)[0];
    	}
    }

    For the second question, the items in State.Configure can not be directly modified from the user interface, for example if you had a property to select the BarsPeriodType, changing it would not affect the already applied indicator. Instead you would need to remove the indicator and re apply it each time.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      1. A WORST PRACTICE is "inline" function calls which waste huge amounts of CPU cycles and memory. AVOID THEM LIKE THE PLAGUE.

      2. Omitting error handling in OnBarUpdate in NT8 is just asking for trouble, and you will get it.

      3. You WILL get bars numbered -1 each time the indicator loads. If you process them they are gonna cause problems.

      4. It's safer to do stuff related to BarsArray[1] when BarsInProgress = 1.

      5. Don't ya just hate that "Java style" bracketing that makes code so hard to read?


      Code:
      [FONT="Book Antiqua"][SIZE="2"]private SMA sma0 = null;
      private SMA sma1 = null;
      private double  a1;
      
      protected override void OnStateChange()
      {
      	if (State == State.SetDefaults)
      	{
      		AddPlot(Brushes.Red, "Plot 0");  [B]//you can use spaces inside a string literal[/B]
      		AddPlot(Brushes.Red, "Plot 1");  [B]//there is no need for unintelligible gibbersih.[/B]
      	}
      	else if (State == State.Configure)
      	{
      	      AddDataSeries(BarsPeriodType.Minute,30);
      	}
              else if (State == State.DataLoaded)
      	{
                    if(sma0 == null)   sma0 = SMA( 12 )[0];
                    if(sma1 == null)   sma1 = SMA(BarsArray[1], 12)[0];
                   [B] //this stuff can be done in State.Configure, or any time thereafter
                    //you could even do it in OnBarUpdate.
                    //just make sure that it is only done ONCE.[/B]
      	}
             
      }
      
      protected override void OnBarUpdate()
      {       if(CurrentBars[0]==-1 || CurrentBars[1]==-1)   
                    return;
      
              if(CurrentBars[1]>1 && BarsInProgress ==1) 
                   a1= sma1[0];
      
      	if(BarsInProgress ==0 && CurrentBars[0] > 1 && CurrentBars[1] > 1 )
              {
      		Values[0][0] = sma0[0];	
      		Values[1][0] = a1;
      	}[/SIZE][/FONT]
      Last edited by Ricam; 03-15-2016, 08:26 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jclose, Today, 09:37 PM
      0 responses
      5 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,414 views
      0 likes
      Last Post Traderontheroad  
      Started by firefoxforum12, Today, 08:53 PM
      0 responses
      11 views
      0 likes
      Last Post firefoxforum12  
      Started by stafe, Today, 08:34 PM
      0 responses
      11 views
      0 likes
      Last Post stafe
      by stafe
       
      Started by sastrades, 01-31-2024, 10:19 PM
      11 responses
      169 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X