Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom indicator not returning expected values

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

    Custom indicator not returning expected values

    Hi... I wrote a custom indicator that I want to use to trigger alerts from Market Analyzer. I have it coded to return 1 if true, 0 if false. As it is now, the column in MA is just showing the last price, not 0 or 1. The on bar update method is below, and I attached a screen shot of the MA settings. Any help would be appreciated..

    Code:
    protected override void OnBarUpdate()
            {
                if(CurrentBar<85)
                {
                    return;
                }
                else
                {
                    if((Close[0]>EMA(50)[0])&&
                       (ToTime(Time[0])<= 140000)&&
                       (Close[0]>Open[0])&&
                       (Volume[0]>=(EMA(Volume,10)[1]))&&
                       (Close[0]>(MAX(High,10)[1]))&&
                       (Slope(EMA(50),11,1)<0)&&
                       (CrossAbove(EMA(10),EMA(20),20))&&
                       (CountIf(delegate {return Close[0]>EMA(20)[0];},10)>4)&&
                       (CountIf(delegate {return (SMA(10)[0]<EMA(20)[0])&&(EMA(20)[0]<EMA(50)[0]);},30)>9)&&
                       (CountIf(delegate {return Low[0]>EMA(50)[0];},10)<3)&&
                       (!(Math.Abs((Slope(EMA(20),7,0)-Slope(EMA(50),7,0))/Slope(EMA(50),10,0))<.05)))
                    {
                       Plot0.Set(1);
                    }
                    else
                    {
                       Plot0.Set(0);
                    }
                }
            }
    Attached Files

    #2
    Hello CSharpTrader,
    Thanks for your post.

    CurrentBar is 0 (zero) based, thus you need to increase the "#no of bars to lookback" to 87, if you are using CalculateOnBarClose == ture or to 86 is you are using CalculateOnBarClose == false.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks much. I'm just curious though, help me understand... I get that it's 0 based, that being the case, wouldn't it just need to be 86 for on bar close? Also, why does on bar open need a different number? Thanks again..

      Comment


        #4
        Hello CSharpTrader,
        When Calculate On Bar Close is set to true, then the running bar is not taken into consideration. Thus you have to add a bar more.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by firstlanetech, Today, 11:31 PM
        0 responses
        2 views
        0 likes
        Last Post firstlanetech  
        Started by AH369, 07-03-2024, 10:17 AM
        8 responses
        832 views
        1 like
        Last Post Karado58  
        Started by FAQtrader, 04-25-2024, 12:00 PM
        58 responses
        1,289 views
        0 likes
        Last Post rene69851  
        Started by kevtancw, Today, 07:09 PM
        0 responses
        4 views
        0 likes
        Last Post kevtancw  
        Started by LanceFulk, Today, 06:28 PM
        0 responses
        6 views
        0 likes
        Last Post LanceFulk  
        Working...
        X