Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Find Max ammounts bars when close is above 10 ema line

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

  • NinjaTrader_Bertrand
    replied
    You are right koganam, thanks for the spot.

    Leave a comment:


  • koganam
    replied
    Originally posted by NinjaTrader_Bertrand View Post
    wallsteetking, would suggest doing the plot outside the condition then resetting the count to 0 if you see a close below the EMA simply.

    if (Close[0] > EMA(10)[0])
    Counter++;
    else
    Counter = 0;

    Plot0.Set(Counter++);
    You mean
    Code:
    Plot0.Set(Counter);

    Leave a comment:


  • wallsteetking
    replied
    Thank you NinjaTrader_Bertrand this is what i was looking for.

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    wallsteetking, would suggest doing the plot outside the condition then resetting the count to 0 if you see a close below the EMA simply.

    if (Close[0] > EMA(10)[0])
    Counter++;
    else
    Counter = 0;

    Plot0.Set(Counter);
    Last edited by NinjaTrader_Bertrand; 09-08-2014, 02:19 AM.

    Leave a comment:


  • wallsteetking
    replied
    I am not quite sure how to implement this.
    Is this correct....
    Code:
    if (Close[0] > EMA(10)[0])
    			
    				{	Counter++;
    					Plot0.Set(Counter++);
    				}
    when I do this I get (see picture) . What I need it to do is if the condition is not met. than start count again from zero.
    Attached Files

    Leave a comment:


  • NinjaTrader_CalH
    replied
    Hello Wallsteetking,

    Thank you for your post.

    This formula starts to subtract when it fails this criteria
    I'm not sure what you mean by this. The CountIf() should maintain the same usage throughout the code.

    If you want to make it an infinite amount you can use CurrentBar in place of 20, however I would not recommend this unless you plan on ignoring the historical in the beginning, Otherwise, it will cause huge delays and lag in the chart.

    My recommendation instead would be to check when the Close is higher than the EMA(10) and then store a counter value

    if(Close[0] > EMA(10)[0])
    counter++;

    let me know if I can be of further assistance.

    Leave a comment:


  • Find Max ammounts bars when close is above 10 ema line

    Hello Ninjatrader Team,

    how can I tell Ninjatrader ( in indicator mode) to tell me what was the Max amount of bars back when the close was higher than the 10 EMA line starting from today going backwards.


    I found this formula online but it not exactly correct.
    Code:
    int NumBullishCandle = CountIf(delegate {return Close[0] > EMA(10)[0];}, 20);
    Plot0.Set(NumBullishCandle);
    This formula starts to subtract when it fails this criteria. Also it maxes out at 20 but I needed it in infinite ammount..

    Also its going to be important to have it in Plot mode. Not print.

    Thank you

Latest Posts

Collapse

Topics Statistics Last Post
Started by ntsomeone, Today, 07:47 AM
0 responses
6 views
0 likes
Last Post ntsomeone  
Started by RJBen, 01-24-2025, 02:39 PM
2 responses
11 views
0 likes
Last Post RJBen
by RJBen
 
Started by ilaniko, Today, 06:22 AM
0 responses
9 views
0 likes
Last Post ilaniko
by ilaniko
 
Started by GeorgeW, 01-12-2025, 11:59 AM
4 responses
46 views
0 likes
Last Post GeorgeW
by GeorgeW
 
Started by CBCharts, Yesterday, 09:35 PM
0 responses
9 views
0 likes
Last Post CBCharts  
Working...
X