Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ninjacript Problem with strategy

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

    ninjacript Problem with strategy

    the problem is the estrategy only realizes one trade per bar. and What I want several trades per bar.



    THE CODE IS THIS:


    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class hh : Strategy
    {
    #region Variables
    // Wizard generated variables
    private double myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    SetStopLoss("", CalculationMode.Ticks, 5, true);
    SetProfitTarget("", CalculationMode.Ticks, 5);

    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (GetCurrentBid() < Open[0])
    {
    EnterShort;
    }

    // Condition set 2
    if (GetCurrentAsk() > Open[0])
    {
    EnterLong;
    }
    }

    #2
    Hello dionisio08, and thank you for your question.

    If you would like to place several trades per bar, you will first need to make sure your EntriesPerDirection setting is higher than one. You will also need to use the overload for EnterLong and EnterShort that allows you to set a quantity. For example, to place 5 trades in a direction :

    EnterLong(5);
    EnterShort(5);

    Here is some relevant help guide documentation for more information.





    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      ninjascript strategy

      i have other problem

      The conditions of the strategy do not work ..... for what?

      I want you to do the same thing you do in the picture





      // Condition set 1
      if (GetCurrentAsk() > Open[0]&&GetCurrentAsk() > High[0])
      {
      EnterLong(5, "");
      }

      // Condition set 2
      if (GetCurrentBid() < Open[0]&&GetCurrentBid() < Low[0])
      {
      EnterShort(5, "");
      Attached Files

      Comment


        #4
        If you would like to place more than one trade per bar, I would like to recommend rather than simply setting CalculateOnBarClose to false, to instead use a more granular data series, such as a 1 second series. Developing a strategy is beyond the scope of the support we may provide, but I will be happy to answer any other questions about the operation of NinjaTrader I can.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        630 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        566 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X