Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help on custom indicator

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

    Help on custom indicator

    Hi,

    I'm new to ninjascripting, so I'm sure there is a simple reason why my script isn't working as planned. All I'm trying to do is have the volume bar paint green if volume is greater than the 50 EMA AND the price bar closes in the top 2/3 of the bar, paint red if it closes in the bottom 2/3, and gray if neither of the above conditions are true.

    Thanks in advance for any help.

    Rich
    Attached Files

    #2
    Originally posted by richp6 View Post
    Hi,

    I'm new to ninjascripting, so I'm sure there is a simple reason why my script isn't working as planned. All I'm trying to do is have the volume bar paint green if volume is greater than the 50 EMA AND the price bar closes in the top 2/3 of the bar, paint red if it closes in the bottom 2/3, and gray if neither of the above conditions are true.

    Thanks in advance for any help.

    Rich
    Your condition:
    Close[0] > (High[0]-Low[0] *.65)

    Two things:

    1. It first multiplies Low[0] by 0.65 then then result is subtracted from High[0]. You should use Close[0] > (High[0] - Low[0]) * 0.65

    2. It's still incorect since you are comparing absolute value with fraction of range.
    If low is 900 and high is 1000 and close is 901 your condition is:
    901 > (1000-900)*0.65 what makes it 901 > 65 which is true. ( you want it to be false)
    So actually your condition has to be:
    Close[0] > Low[0] + (High[0] - Low[0])*0.65
    901 > 900 + (1000 -900)*0.65
    901 > 965 - false

    Same with other condition:

    Close[0] < Low[0] + (High[0] -Low[0]) * 0.35

    Final:

    if (VOL()[0] > VOLMA(50)[0] && Close[0] > Low[0] + (High[0]-Low[0]) *0.65)
    Up0.Set(Volume[0]);
    else
    if (VOL()[0] > VOLMA(50)[0] && Close[0] < Low[0] + (High[0]-Low[0]) *0.35)
    Down0.Set(Volume[0]);
    else
    Close0.Set(Volume[0]);

    Hope it helps
    Last edited by roonius; 04-11-2009, 06:13 PM.

    Comment


      #3
      Boy I was sloppy. I was so concerned about the syntax I apparently lost all mathematical logic! Thanks for setting me straight on that one.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, 04-16-2024, 06:09 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by RookieTrader, Today, 07:41 AM
      0 responses
      2 views
      0 likes
      Last Post RookieTrader  
      Started by maybeimnotrader, Yesterday, 05:46 PM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Perr0Grande, Yesterday, 08:16 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by f.saeidi, Yesterday, 08:12 AM
      3 responses
      26 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X