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 ZenCortexAuCost, Today, 04:24 AM
      0 responses
      2 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by ZenCortexAuCost, Today, 04:22 AM
      0 responses
      0 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      13 views
      0 likes
      Last Post SantoshXX  
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      2 views
      0 likes
      Last Post DanielTynera  
      Started by yertle, 04-18-2024, 08:38 AM
      9 responses
      42 views
      0 likes
      Last Post yertle
      by yertle
       
      Working...
      X