• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to CrossBelow and CrossAbove with a delta ("thickness")?

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

    How to CrossBelow and CrossAbove with a delta ("thickness")?

    Hey guys! I am new to NinjaScripting.

    Lets for example look at a simple MA crossover strategy:
    Code:
    if (CrossBelow(SMA1, SMA2, 1))
       EnterShort(...);
    But I want it to have a thickness (aka Delta, aka "Vertical offset") for the SMA2, for example an offset of 3 pips for the SMA2, so it won't count as a cross, until it crosses down the (SMA-4pips)

    So the default variant is:


    And that's what I want:

    #2
    Hello Lionell,

    Welcome to the NinjaTrader support forum.

    In this case, the method being used "CrossBelow" has two ways it can be used. You have highlighted the first use or two DataSeries being compared. You can also compare a DataSeries against a Double which could be any calculated value. https://ninjatrader.com/support/help...sub=crossbelow

    For a single modification of price, you could pre-calculate the offset value you want to compare, and then supply that value to CrossBelow.

    For example, you could do something like the following:

    Code:
    double sma2Calculated = SMA2[0] - amountOfPips;
    if (CrossBelow(SMA1, sma2Calculated , 1))
    replacing amountOfPips with the amount you wanted to subtract from the SMA.

    If you need multiple offsets to make a thicker area or band of an existing plot, you have a few options. One way is to create an indicator that plots these calculated values as two separate plots. You could then replace the SMA and SMA2 with your indicator, using its Plots in the condition.

    Another approach would be to use DataSeries to hold data which can also be supplied to CrossBelow. As you cannot use CrossBelow to do a comparison between two doubles, you can fill in two DataSeries and use those with CrossBelow instead. There are some examples of creating series here: https://ninjatrader.com/support/help...sub=dataseries which could then be used in CrossBelow in place of the SMAs.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for the help Jesse!

      I got another question:
      I created and tested a few strategies with "1 min Heiken Ashi" data. When I am to check out "Strategy Performance -> Historical", the results are pretty good.
      But when I switch to ordinary 1 min chart (data), the results are much worse.

      So the question is: does "historical strategy perfomance" tool calculate profits with Historical data using Heiken Ashi correct? Or Heiken Ashi just "redraws", like Forex MetaTrader developers usually say in slang about some indicators?

      Comment


        #4
        Hello Lionell,

        Thank you for the reply.

        This is due to how Heiken Ashi Bars are built. Heiken Ashi Bars draw very different Open High Low, and Close values from their Base Bars Type in most cases. This means the Backtesting Historical Fill Logic is using the Heiken Ashi Bars Type with different OHLC than the base Bars Type to calculate executions.

        To change the behavior to more closely match up to the market you can enable High Fill Order Resolution or implement a second series in their strategy to submit orders to. You can still see differences as historical tests are executed differently.

        https://ninjatrader.com/support/help...lightsub=discr

        Please see the High Fill Order Resolution information at the following link: https://ninjatrader.com/support/help...FillResolution
        Please find our reference sample on submitting to an additional bar series at the following link: https://ninjatrader.com/support/foru...ead.php?t=6652


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by U0000999, Yesterday, 11:49 PM
        2 responses
        6 views
        0 likes
        Last Post U0000999  
        Started by Mberg, Today, 03:29 AM
        0 responses
        4 views
        0 likes
        Last Post Mberg
        by Mberg
         
        Started by TazoTodua, Today, 03:24 AM
        0 responses
        4 views
        0 likes
        Last Post TazoTodua  
        Started by ahadari28, Yesterday, 04:01 PM
        2 responses
        9 views
        0 likes
        Last Post ahadari28  
        Started by NinjaCustomer, Today, 12:14 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Marco  
        Working...
        X