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

How to pick different outputs from an indicator for strategy

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

    How to pick different outputs from an indicator for strategy

    Hi,

    I've so far had total failure getting a strategy to even function - never mind make a profit - using MACD. I think I must be doing something wrong.

    The MACD indicator has three outputs: the two lines and the difference graph. I was wanting to reference the difference in a strategy, but I couldn't seem to get it to make any trades when there was an 'IF ALL' condition that included comparing the MACD diff to a threshold value as a parameter, even when I set it to 0. When I set it 'IF ANY', when I looked at the graph of transactions after optimising, the only transactions were from the other criteria, not MACD.

    I THINK I'm doing it correctly. In the strategy builder, when I've selected MACD, I have three user parameters for the fast, slow and smooth parameters, which are set to the same values as on a graph I'm displaying outside the strategy. Under 'plots', I've selected 'diff', as that's the value I want to compare to my threshold value as I couldn't see any other way of selecting that particular output, which is set to zero in the strategy analyser. But even though the MACD difference clearly oscillates around zero in the graph I'm displaying on a separate screen, even when the conditions and actions screen is set to 'if any', it never chooses to do any transactions based on MACD. So I'm wondering if I'm specifying the MACD correctly in the strategy.

    In the strategy builder, the line that defines the MACD strategy comes out like this:

    CrossAbove(MACD(Close, Convert.ToInt32(MACDfast), Convert.ToInt32(MACDslow), Convert.ToInt32(MACDsignal)).Diff, MACDthreshold, 0)

    I don't know why there is 'convert.toint32(MACDfast)' as those parameters are all defined as integers anyway, whereas the MACDthreshold is defined as a Double.

    Any light shed would be gratefully received.
    Last edited by herseem; 01-01-2018, 11:50 AM.

    #2
    Hello herseem,

    Thank you for your note.

    When you enable the strategy are you seeing any errors on the log tab of the control center? Perhaps about an order being ignored?

    I put together a sample strategy which will go long when the Diff crosses above 0, and go short when the diff crosses below 0. Its important that when you enable the strategy, in the strategies properties, you set BarsRequiredToTrade to 0, otherwise you will get an error and the strategy will not take any trades.

    See BarsRequiredToTrade section of our helpguide,


    To Import a NinjaScript into NinjaTrader 8 do the following:
    From the Control Center window select Tools -> Import-> NinjaScript...
    Find the file location.

    Please import the strategy and test on your end. Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi AlanP,

      I do indeed have log errors - "An order placed at xx/xx/xx has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met"

      I'll try changing that property and also test the strategy you referenced and get back to you. Thanks for the outstandingly speedy response, on New Years day too! You'll be mentioned in despatches.

      Comment


        #4
        Ok, what seems to have been the root of the original problem is that somehow the input parameters ended up having a function 'convert.toint32' wrapped round them. I don't know why that happened as I can't work out what I did differently this time from last time. I haven't changed the definition of the parameters, but somehow this time they're entered normally and it works fine.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gm7_forum, Today, 05:51 PM
        0 responses
        2 views
        0 likes
        Last Post gm7_forum  
        Started by cre8able, Today, 03:20 PM
        1 response
        9 views
        0 likes
        Last Post cre8able  
        Started by fiddich, Today, 05:25 PM
        0 responses
        3 views
        0 likes
        Last Post fiddich
        by fiddich
         
        Started by gemify, 11-11-2022, 11:52 AM
        6 responses
        804 views
        2 likes
        Last Post ultls
        by ultls
         
        Started by ScottWalsh, Today, 04:52 PM
        0 responses
        4 views
        0 likes
        Last Post ScottWalsh  
        Working...
        X