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 aligator, 01-06-2022, 12:14 PM
      4 responses
      235 views
      0 likes
      Last Post john_44573  
      Started by reynoldsn, Today, 05:56 PM
      0 responses
      5 views
      0 likes
      Last Post reynoldsn  
      Started by bortz, 11-06-2023, 08:04 AM
      51 responses
      1,990 views
      0 likes
      Last Post aligator  
      Started by dmking, 11-12-2019, 12:31 PM
      4 responses
      4,150 views
      0 likes
      Last Post jasonw
      by jasonw
       
      Started by roblogic, Today, 04:31 PM
      0 responses
      10 views
      0 likes
      Last Post roblogic  
      Working...
      X