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

Second Indicator's Parameters Don't Change

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

    Second Indicator's Parameters Don't Change

    Hey there everyone,

    I am trying to compare 2 indicators to make an entry/exit or both. The logic is if second indicator's value CrossAbove first indicator's value, then it should enter/exit a position. This logic works for RSI (Relative Strength Index) and other indicators but not for APZ (Adaptive Price Zone). Apparently, in Data Box on the chart, first and second indicator's parameters are the same when it should not be. Both indicators have the same value as a result. They never cross each other. Can someone enlighten me of what's happening.

    My code is like this

    Code:
    // [B]ind.indicator[/B] - Indicator object
    // i[B]ndSeriesNewVal [/B]- Holds an [B]OHLC (Open High Low Close) [/B]price value . I selected [U]Close price[/U]
    // [B]ind.customSigPeriod[/B] - Holds value of period
    
    if (CrossAbove(ind.indicator.Values[ind.sigValueIndex], APZ(indSeriesNewVal, 2, ind.customSigPeriod).Lower, 1)) EnterPosition();


    APZ Chart

    Click image for larger version

Name:	screenshot.PNG
Views:	188
Size:	22.4 KB
ID:	1187523Click image for larger version

Name:	screenshot-2.PNG
Views:	180
Size:	39.2 KB
ID:	1187524


    RSI Chart

    Click image for larger version

Name:	screenshot-4.PNG
Views:	165
Size:	21.2 KB
ID:	1187521Click image for larger version

Name:	screenshot-3.PNG
Views:	176
Size:	108.1 KB
ID:	1187522
    Attached Files

    #2
    Hello itgoesbrrrrrr,

    Thank you for your post.

    The code provided does not appear to be how we would normally format NinjaScript and the screenshots provided appear to be of a third party add-on called StratGen, which we could not advise on details of making a strategy using as it is a third party item and you would need to reach out to them for troubleshooting.

    However, I'm attaching a simple example of a NinjaScript strategy built using the Strategy Builder that will enter long when an APZ with a period of 14 and a band width of 2's upper band crosses a 20 period APZ with a band with of 2's upper band as an illustration of how this can be built using the Strategy Builder. My suspicion is that since the APZ requires 2 parameters to be called, the period and the band width, that this add-on scripting solution you have is not programmed to get both of those parameters to properly call the APZ.

    You can import the example script from Tools > Import NinjaScript Add On. If it asks you if you want to replace an existing indicator when you import it, say no. You can then open this by opening a new Strategy Builder window and selecting "SimpleAPZCrossEntry" from the drop down on the first screen, then clicking Next to move through the builder screens. You can also view the actual NinjaScript code in ;use by selecting the View Code button in the Builder.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cre8able, Today, 01:16 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by chbruno, 04-24-2024, 04:10 PM
    3 responses
    48 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by samish18, Today, 01:01 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by WHICKED, Today, 12:56 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by WHICKED, Today, 12:45 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X