Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple EnterLongStops

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

    Multiple EnterLongStops

    I have developed a strategy that generates multiple price levels to enter at.

    All of these will not get hit on the next bar

    So here are my questions:

    1. How can i store these levels so i can use them later (should i use a dataseries object) because if i submit all these enterLongStops, i am afraid my broker wont accept because of margin...lol
    2. how do i determine which price is closest to market so i can submit orders? one may be short and another long
    3. how do i tell if order filled so i can remove it from (dataseries?) because each level gets used once

    Not sure if I made myself clear, but anyone who is really good at programming this should be a no brainer for ya!

    I guess i would ike a framework to store levels
    execute orders on those levels
    confirm fills
    then delete levels

    Thanks

    #2
    Originally posted by Laserdan View Post
    I have developed a strategy that generates multiple price levels to enter at.

    All of these will not get hit on the next bar

    So here are my questions:

    1. How can i store these levels so i can use them later (should i use a dataseries object) because if i submit all these enterLongStops, i am afraid my broker wont accept because of margin...lol
    2. how do i determine which price is closest to market so i can submit orders? one may be short and another long
    3. how do i tell if order filled so i can remove it from (dataseries?) because each level gets used once

    Not sure if I made myself clear, but anyone who is really good at programming this should be a no brainer for ya!

    I guess i would ike a framework to store levels
    execute orders on those levels
    confirm fills
    then delete levels

    Thanks

    Hi LaserDan


    I have done a similiar thing ...I'm not saying this is perfect (as i just typed it in- probably some typo's etc) but it should give you the basis on which to add some code to your strategy ...

    /////////////////////
    /// variables
    /////////////////////

    static int LONG =1;
    static in SHORT = -1;

    List<double>listLongOrderLevels = new List<double>();
    List<double>listShortOrderLevels = new List<double>();
    List<IOrder>listOpenOrders = new List<IOrder>();

    //////////////////////
    //////////////////////
    //////////////////////

    1. Add your long/short levels to the long order list => AddToOrderLevels(double prc, int LS)
    3. Find And Remove your order placement levels from the Long level List => private double FindNearestLongLevel ()
    4. Find And Remove your order placement levels from the Short level List => private double FindNearestShortLevel ()
    5. Place Order = > PlaceMyOrder(double prc, int LongOrShort)
    6. Order will be removed from your open order list in the override of OnExecution


    //////////////////////
    //////////////////////
    //////////////////////

    protected override void OnExecution(IExecution execution) {
    for (int i=0;i<listOpenOrders.Count;i++) {
    if ( listOpenOrders[i].Token == execution.Order.Token) {
    listOpenOrders.RemoveAt(i);
    break;
    }
    }
    }

    //////////////////////
    //////////////////////
    //////////////////////

    private void PlaceMyOrder (double prc, int LS) {

    if (LS == LONG) listOpenOrders.Add(EnterLongLimit(.....));
    else if (LS == SHORT) listOpenOrders.Add(EnterShortLimit(.....));
    }

    //////////////////////
    //////////////////////
    //////////////////////

    private void AddToOrderLevels(double prc, int LS) {

    if (LS == LONG) listLongOrderLevels.Add(prc);
    else if (LS == SHORT) listShortOrderLevels.Add(prc);

    }

    //////////////////////
    //////////////////////
    //////////////////////

    private double FindNearestLongLevel () {

    double diff = 0;
    double d;
    int iPos = -1;


    for (int i=0; i< listLongOrderLevels.Count; i++ ) {

    d = Close[0] - listLongOrderLevels[i];

    if (d > TickSize && (d < diff || diff == 0)) iPos = i;
    }

    if (iPos > -1) {
    d = listLongOrderLevles[i];
    listLongOrderLevels.RemoveAt(i);
    return (d);
    } else return 0;

    }

    //////////////////////
    //////////////////////
    //////////////////////

    private double FindNearestShortLevel() {

    double diff = 0;
    double d;
    int iPos = -1;


    for (int i=0; i< listShortOrderLevels.Count; i++ ) {

    d = listShortOrderLevels[i] - Close[i];

    if (d > TickSize && (d < diff || diff == 0)) iPos = i;
    }

    if (iPos > -1) {
    d = listShortOrderLevels[i];
    listShortOrderLevels.RemoveAt(i);
    return (d);
    } else return 0;

    }

    Comment


      #3
      THANK YOU!!

      The List Item with the FindNearest Functions are Exactly what i was looking for. Thanks for showing me this and hopefully it will help others as well.

      Comment


        #4
        Originally posted by Laserdan View Post
        THANK YOU!!

        The List Item with the FindNearest Functions are Exactly what i was looking for. Thanks for showing me this and hopefully it will help others as well.
        u r welcome!

        Comment

        Latest Posts

        Collapse

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