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 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.



        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 ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Working...
        X