Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 elirion, Today, 09:32 PM
    0 responses
    2 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by cre8able, Today, 09:15 PM
    1 response
    5 views
    0 likes
    Last Post bltdavid  
    Started by cummish, Today, 08:43 PM
    0 responses
    9 views
    0 likes
    Last Post cummish
    by cummish
     
    Started by Option Whisperer, Today, 07:58 PM
    4 responses
    20 views
    0 likes
    Last Post Option Whisperer  
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    13 responses
    87 views
    0 likes
    Last Post ETFVoyageur  
    Working...
    X