Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to have bot enter every X minutes

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

    How to have bot enter every X minutes

    Hello,

    I trade the ES market.

    I am building a strategy manually through ninjascript. The strategy only operates between the hours of 8:30:05 AM and 12:00PM. I would like to know how to have the strategy enter either long or short every, say 15 minutes, within that timeframe?
    below is a portion of of the script:

    Dataseries: ...Minute, 15);

    if ((ToTime(Time[0]) >= startTime && ToTime(Time[0]) < endTime))
    {
    if (Close[0] > Open[0])
    EnterShortStopMarket(0,true,Convert.ToInt32(OrderQ uantity), ShortEntryPrice, "ShortEntryPrice");
    }

    The strategy enters fine the first time; however, on its second time, I receive an error that reads "short stop order cannot be placed above market price".
    In this back test scenario, the historical market price on second entry is higher than the market price on the first entry.


    Thanks in advance.

    #2
    Hello Don22Trader1,

    The error you are seeing is likely that the price you are using is not valid when submitting the order. I don't see that you are calculating a price before submitting it, if you are not calculating a new price at the time you submit the order that would be the problem.

    Comment


      #3
      The entry price is stated as ShortEntryPrice, and that value is defined as shown below:

      private double ShortEntryPrice;
      private int ShortEntryTicks = 4;

      OnBarUpdate()

      if (Position.MarketPosition == MarketPosition.Flat)
      {
      ShortEntryPrice = (Close[0] - (ShortEntryTicks * TickSize));
      }

      Basically I am looking to have the strategy enter 4 ticks below the close of the previous 15 minute bar and have it run continuously within the time frame of 8:30:05 AM - 12:00 PM.

      Comment


        #4
        Hello Don22Trader1,

        You may want to move that logic setting the variable to before the entry inside the entry condition so that a valid price is calculated at that time. I can't tell from the split up samples where that code exists in contrast to the entry at this point. You would otherwise need to check that the price is valid before submitting the order, if its not valid you would need to set some other price or not submit the order.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        51 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        127 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X