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

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 ScottW, Today, 06:09 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottWalsh, Today, 06:52 PM
        0 responses
        3 views
        0 likes
        Last Post ScottWalsh  
        Started by ftsc2022, 10-25-2022, 12:03 PM
        5 responses
        256 views
        0 likes
        Last Post KeyonMatthews  
        Started by Board game geek, 10-29-2023, 12:00 PM
        14 responses
        244 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Waxavi, 04-19-2024, 02:10 AM
        4 responses
        56 views
        0 likes
        Last Post sonia0101  
        Working...
        X