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

Pinscript to Ninja

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

    Pinscript to Ninja

    Hello,

    I have the following code in Pinescript and having some trouble converting to Ninja. appreciate the help

    longcheck = (ema1 - ema1[1]) / ema1[1] * 100
    confirmlong = ta.ema(longcheck, 30)​

    i would think longcheck is singular value but it is returning a series and ema is being extraced off it. i tried similar thing in Ninjascript but it is complaining that longcheck cannot be of type iseries..
    the code executes fine in Tradingview

    Ninja

    longcheck = (ema1[0] - ema1[1]) / ema1[1] * 100 - How can i convert this to an iseries??
    confirmlong = EMA(longcheck, 30)​
    Last edited by nagesh789; 12-13-2023, 06:57 AM.

    #2
    Hello nagesh789,

    Thank you for your post.


    Code:
    private Series<double> longcheck;
    
    longcheck[0] = (ema1[0] - ema1[1]) / ema1[1]*100



    The EMA takes an ISeries<double> input, so if you want to use longcheck to calculate the EMA, longcheck needs to be an ISeries<double>.

    EMA(ISeries<double> input, int period)[int barsAgo]

    EMA - https://ninjatrader.com/support/help...onential_e.htm

    Please see the Help Guide page below which has a code snippet demonstrating defining, assigning, and using Series<double>.

    Series<T> - https://ninjatrader.com/support/help...t8/seriest.htm

    Please let me know if you have any other questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the help and that worked. i have a follow up question on HA candles. I'm using HeikenAshi8 indicator in my code and my strategy uses ADX, RSI, EMA etc to generate signals. i tried checking like HeikenAshi8.RSI but it is not making any difference compared to normal candles in the backtest. The signals are appearing at the same place with or without the indicator. There are specific HAClose and Open but my strat doesn't rely on them.

      i'm sure i'm doing something wrong here. Can you please provide some guidance on how to calculate RSI etc when using HeikenAshi8?

      Comment


        #4
        Hello,

        If you're going to be backtesting a Heiken Ashi strategy, you should be aware that Heiken-Ashi candles present false information concerning each candle.


        Here is how the Heiken-ashi is calculated:

        HAClose = ((Open[0] + High[0] + Low[0] + Close[0]) * 0.25); // Calculate the close

        HAOpen = ((HAOpen[1] + HAClose[1]) * 0.5); // Calculate the open

        HAHigh = (Math.Max(High[0], HAOpen[0])); // Calculate the high

        HALow = (Math.Min(Low[0], HAOpen[0])); // Calculate the low


        When you place an order it can only fill on real price data.

        The strategy analyzer does not know what the base data is that created the Heiken-Ashi bar and it will backtest based on the false information presented.

        A work around, for backtesting in the strategy analyzer, would be to use the indicator HeikenAshi8 in your strategy and use standard bars in the chart/analyzer so that the backtest results are based on real data points and your strategy can use the Heiken-ashi values for your entry conditions


        Another option would be to backtest your strategy using the Playback Connection so that the bars may be built more realistically as if they were in real time.

        Playback - https://ninjatrader.com/support/help...connection.htm


        Please let us know if you have any other questions.
        Gaby V.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ChartTourist, Today, 08:22 AM
        0 responses
        4 views
        0 likes
        Last Post ChartTourist  
        Started by LiamTwine, Today, 08:10 AM
        0 responses
        2 views
        0 likes
        Last Post LiamTwine  
        Started by Balage0922, Today, 07:38 AM
        0 responses
        5 views
        0 likes
        Last Post Balage0922  
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        19 views
        0 likes
        Last Post Massinisa  
        Working...
        X