Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Looking for Divergence in price swings

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

    Looking for Divergence in price swings

    Hello,

    I would like to know what I have done wrong here. I cant compile.

    If price makes new high and indicator Rvalue does not, I would like to draw a error down.

    The problem is how do I tell the strategy to look for the last swing high and take the indicator value on that bar... the bold marked is the source of the error.

    RValueChart(VCLen).VClose[0] < RValueChart(VCLen).VClose[Swing(Swing(SwingStrength).SwingHighBar(1,1,SwingL ookBackPeriod)])




    Code:
    protected override void OnBarUpdate()
            {
    		if(High[0] > Swing(SwingStrength).SwingHigh[0]
                    && RValueChart(VCLen).VClose[0] < RValueChart(VCLen).VClose[Swing(Swing(SwingStrength).SwingHighBar(1,1,SwingLookBackPeriod)])
    			{
    				DrawArrowDown("My down arrow" + CurrentBar, 0, High[0] + 5 * TickSize, Color.Red);
    			}
            }

    #2
    Hello prisonbreaker82,

    It looks like it is a problem with the syntax. From the looks of your code you are trying to get the number of bars ago of the SwingHighBar like:

    Code:
    Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod);
    You may try something like the following:

    Code:
    RValueChart(VCLen).VClose[Swing(SwingStrength).SwingHighBar(1,1,SwingLookBackPeriod)]
    Note that the Swing indicator can have their plot points recalculated as incoming data is updated, thus making it challenging to use in a strategy via programmatic calls. They are first and foremost mean to be used as visual trading tools.

    With that said you can still use the indicators for your calculations but would need to understand what price points can be accessed at which time programmatically, since those can be different from the historically plotted ones.

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    649 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    370 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    576 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X