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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    65 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    149 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    99 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    286 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X