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

Need help in coding

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

    Need help in coding

    I need to code below strategy in ninja.


    1) Plot 4H close line and open line on the chart
    2) Do following based on chart resolution :
    a) 15Min chart
    15Min close > 4H Close -> Go Long on next candle open

    b) 1Hr chart
    1Hr close > 4H Close -> Go Long on next candle open

    So based on chart resolution it should check for close with 4Hr close.

    3) If 15Min close < 4H Open-> Go Short on next candle open

    I have this strategy in TradingView pinescript just need to convert it in ninjascript :
    PineScript Code :

    ================================================== ===============
    imeF=input('240') //4H
    precision=input(0.05)
    openPrice = security(tickerid, timeF, open)
    closePrice = security(tickerid, timeF, close)

    plot(openPrice,color=red,linewidth=4)
    plot(closePrice,color=green,linewidth=4)

    goLongValue=(closePrice - openPrice)*100/openPrice
    goShortValue=(openPrice - closePrice)*100/closePrice

    longCondition = goLongValue > precision
    shortCondition = goShortValue > precision

    if (longCondition)
    strategy.entry("long", strategy.long)
    if (shortCondition)
    strategy.entry("short", strategy.short)
    ================================================== ===============

    #2
    Need help in coding

    Hello satty007,

    Thanks for writing in to our Support team.

    First, you would need to Add a 240 minute(or 4 hour) data series by calling the Add() method in Initialize(). Then, you need to create your plots as properties so that you are able to set them to whatever value you wish.

    You can access price information of different dataseries with the Closes and Opens objects. You can provide an index value to reference values other than the current bar as well as a barSeriesIndex to denote what data series it should be pulling the price data from.

    You can call the EnterLong() and EnterShort() methods to submit long/short entries.

    For more information on all of these methods and objects, please refer to the following links in our help guide below:

    Add() - http://ninjatrader.com/support/helpGuides/nt7/add3.htm

    Plots - http://ninjatrader.com/support/helpGuides/nt7/plots.htm

    Closes - http://ninjatrader.com/support/helpG...nt7/closes.htm

    Opens - http://ninjatrader.com/support/helpGuides/nt7/opens.htm

    EnterLong() - http://ninjatrader.com/support/helpG.../enterlong.htm

    EnterShort() - http://ninjatrader.com/support/helpG...entershort.htm

    For future reference, we do not provide code conversion services to clients, but are more than happy to provide documentation and examples which illustrate what you are trying to achieve.

    Please let me know if I may be of any further assistance.
    Alan S.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by aa731, Today, 02:54 AM
    0 responses
    4 views
    0 likes
    Last Post aa731
    by aa731
     
    Started by thanajo, 05-04-2021, 02:11 AM
    3 responses
    470 views
    0 likes
    Last Post tradingnasdaqprueba  
    Started by Christopher_R, Today, 12:29 AM
    0 responses
    10 views
    0 likes
    Last Post Christopher_R  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    166 responses
    2,237 views
    0 likes
    Last Post sidlercom80  
    Started by thread, Yesterday, 11:58 PM
    0 responses
    4 views
    0 likes
    Last Post thread
    by thread
     
    Working...
    X