• 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

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 TazoTodua, Today, 12:21 AM
    0 responses
    7 views
    0 likes
    Last Post TazoTodua  
    Started by U0000999, Today, 12:20 AM
    0 responses
    7 views
    0 likes
    Last Post U0000999  
    Started by sidviciousX, Yesterday, 06:47 AM
    1 response
    21 views
    0 likes
    Last Post bltdavid  
    Started by Mykro, Yesterday, 10:22 PM
    0 responses
    7 views
    0 likes
    Last Post Mykro
    by Mykro
     
    Started by rudccv, Yesterday, 08:42 PM
    0 responses
    6 views
    0 likes
    Last Post rudccv
    by rudccv
     
    Working...
    X