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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X