Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SubmitOrder using Absolute value

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

    SubmitOrder using Absolute value

    Hello,

    I am trying to create an Unmanaged Bracket order using SubmitOrder. How do I include an absolute value? In other words for example I want to enter the market if I eventually get touched 23 ticks away from the current Close[0].

    I tried the followitng below however I got an error concerning an attempt to place a BuyLimit or Buy Stop below the market and it quoted a small value of 161.1 ( for gold )

    tickLimit = Close[0] + 10;

    longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 1, tickLimit * TickSize, tickLimit * TickSize, String.Format("G1"), "long limit entry");

    shortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 1, tickLimit * TickSize, tickLimit * TickSize, String.Format("G1), "Short limit entry");

    #2
    Hello cocopod,

    Thank you for your post.

    I do not understand your logic in the code. For 23 ticks above I would use the following:
    Code:
    tickLimit = Close[0] + (23*TickSize);
    Then call that in your Stop Price for Long.
    You would likely need a negative value for Short, so you would use the following:
    Code:
    tickLimitLong = Close[0] + (23*TickSize);
    tickLimitShort = Close[0] - (23*TickSize);

    Comment


      #3
      Didn't work!!

      I got the following error

      Buy Stop or Buy stop limit orders can't be placed below he market affected Order : Buy 1 Stop @115.4. My code for the bracket is below

      tickLimitLong = Close[0] + (23*TickSize);
      tickLimitShort = Close[0] - (23*TickSize);
      longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 1, tickLimitLong * TickSize, tickLimitLong * TickSize, String.Format("Gold" + qty), "long limit entry" + tickPrice);
      shortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 1, tickLimitShort * TickSize, tickLimitShort * TickSize, String.Format("Gold" + qty), "Short limit entry" + tickPrice);

      Comment


        #4
        Below is a subset of the trace file.. Looks like the field size is strangely limited to 4 characters


        /Replay101' Name='long limit entry1151.3' New state=Initialized Instrument='GC 12-14' Action=Buy Limit price=0 Stop price=115.4 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
        2014-11-24 09:47:53:928 (Market Replay Connection) Cbi.Order.Update1: oldid='c52a808f509248ce85d81647131972f6' Order='c52a808f509248ce85d81647131972f6/Replay101' Name='long limit entry1151.3' New state=Initialized Instrument='GC 12-14' Action=Buy Limit price=0 Stop price=115.4 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
        2014-11-24 09:47:53:944 (Market Replay Connection) Cbi.Order.Submit: Order='c52a808f509248ce85d81647131972f6/Replay101' Name='long limit entry1151.3' State=Initialized Instrument='GC 12-14' Action=Buy Limit price=0 Stop price=115.4 Quantity=1 Strategy='GoldSpike' Type=Stop Tif=Gtc Oco='Gold1' Filled=0 Fill price=0 Token='47720a7229894513a63ab471bc898b75' Gtd='01/12/2099 00:00:00'
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Simulator.Submit: Order='c52a808f509248ce85d81647131972f6/Replay101' Name='long limit entry1151.3' State=Initialized Instrument='GC 12-14' Action=Buy Limit price=0 Stop price=115.4 Quantity=1 Strategy='GoldSpike' Type=Stop Tif=Gtc Oco='Gold1' Filled=0 Fill price=0 Token='47720a7229894513a63ab471bc898b75' Gtd='01/12/2099 00:00:00'
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='47720a7229894513a63ab471bc898b75/Replay101' Name='long limit entry1151.3' New state=Rejected Instrument='GC 12-14' Action=Buy Limit price=0 Stop price=115.4 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=OrderRejected Native error='Buy stop or buy stop limit orders can't be placed below the market.'
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Order.Update1: oldid='c52a808f509248ce85d81647131972f6' Order='47720a7229894513a63ab471bc898b75/Replay101' Name='long limit entry1151.3' New state=Rejected Instrument='GC 12-14' Action=Buy Limit price=0 Stop price=115.4 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=OrderRejected Native error='Buy stop or buy stop limit orders can't be placed below the market.'
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventAr gs: Order='9c6f41cb090044959fb47827bea2dd28/Replay101' Name='Short limit entry1151.3' New state=Initialized Instrument='GC 12-14' Action=SellShort Limit price=0 Stop price=114.9 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Order.Update1: oldid='9c6f41cb090044959fb47827bea2dd28' Order='9c6f41cb090044959fb47827bea2dd28/Replay101' Name='Short limit entry1151.3' New state=Initialized Instrument='GC 12-14' Action=SellShort Limit price=0 Stop price=114.9 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Order.Submit: Order='9c6f41cb090044959fb47827bea2dd28/Replay101' Name='Short limit entry1151.3' State=Initialized Instrument='GC 12-14' Action=SellShort Limit price=0 Stop price=114.9 Quantity=1 Strategy='GoldSpike' Type=Stop Tif=Gtc Oco='Gold1' Filled=0 Fill price=0 Token='4fbb1af66165412cb736aecb063552b9' Gtd='01/12/2099 00:00:00'
        2014-11-24 09:47:53:960 (Market Replay Connection) Cbi.Simulator.Submit: Order='9c6f41cb090044959fb47827bea2dd28/Replay101' Name='Short limit entry1151.3' State=Initialized Instrument='GC 12-14' Action=SellShort Limit price=0 Stop price=114.9 Quantity=1 Strategy='GoldSpike' Type=Stop Tif=Gtc Oco='Gold1' Filled=0 Fill price=0 Token='4fbb1af66165412cb736aecb063552b9' Gtd='01/12/2099 00:00:00'

        Comment


          #5
          Below are the definitions

          Below are the definitions

          private double tickLimitLong = 1;
          private double tickLimitShort = 1;

          Comment


            #6
            Don't you guys work on Mondays??!!

            Can someone help to resolve this please??!!

            Comment


              #7
              Hello cocopod,

              Do not multiply the values in the SubmitOrder() method. They are already multiplied by TickSize, no need to repeat that again. So the code would reflect the following:
              Code:
              tickLimitLong = Close[0] + (23*TickSize);
              tickLimitShort = Close[0] - (23*TickSize);
              
              longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 1, 0, tickLimitLong, String.Format("G1"), "long limit entry");
              
              shortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 1, 0, tickLimitShort, String.Format("G1), "Short limit entry");

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              573 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X