Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

atm with auto trail

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

    atm with auto trail

    Good morning, I have a problem with ATM orders, my goal is that there can only be one order executed at a time but I have observed that new order is triggered


    Click image for larger version  Name:	image.png Views:	2 Size:	363.3 KB ID:	1302435
    Last edited by dcriador; 05-06-2024, 01:48 AM.

    #2
    Me code:
    if (atmStrategyId.Length > 0)
    {
    string[] status = GetAtmStrategyEntryOrderStatus(atmStrategyId);

    // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
    if (status.GetLength(0) > 0)
    {
    // Print out some information about the order to the output window
    Print("The entry order average fill price is: " + status[0]);
    Print("The entry order filled amount is: " + status[1]);
    Print("The entry order order state is: " + status[2]);

    // If the order state is terminal, reset the order id value
    if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected"){
    Print("borro la id");
    Print("PnL is " + GetAtmStrategyRealizedProfitLoss(atmStrategyId).To String());
    Print("GetAtmStrategyUnrealizedProfitLoss " + GetAtmStrategyRealizedProfitLoss(atmStrategyId).To String());
    atmStrategyId = string.Empty;
    } else if (status[2] == "PartiallyFilled") {
    // Manejar específicamente el caso de cierre parcial
    return; // Detener la ejecución para evitar nuevas órdenes
    } else {
    return; // Si la orden no está terminada, detener la ejecución
    }
    }

    } // If the strategy has terminated reset the strategy id
    else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat){

    atmStrategyId = string.Empty;
    }​

    Comment


      #3
      Hello dcriador,

      Have you tried using a print to check which parts of your logic are happening when you see that occur?

      We suggest modeling your logic after the SampleATMStrategy which only places a single ATM at a time. It uses the strings you generate to know the order is active and only clears those strings when the order is not active. if you tried to do that in your own script but it is not working you would need to use prints to see where the problem is happening at.

      Comment


        #4
        I use this code but not work well, the status of order is filled but the order continues open. There are not any function of getatmstate(id) to know if status of atm is terminated
        Last edited by dcriador; 05-06-2024, 11:20 PM.

        Comment


          #5
          Hello dcriador,

          can you show how you are trying to check the status of the order? In the sample that is the following logic:

          Code:
          if (orderId.Length > 0)
          {
          string[] status = GetAtmStrategyEntryOrderStatus(orderId);
          if (status.GetLength(0) > 0)
          {
              // If the order state is terminal, reset the order id value
             if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                orderId = string.Empty;
          }
          } 
          else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
             atmStrategyId = string.Empty;​

          Comment


            #6
            I use the same code that you write but dont work fine, It makes no sense for it to fail because the order, once closed, should come as filled, but I am receiving the order without closing and with a filled status.The only way I have found to capture it well is to use getatmorderstatus, I check if it exists and if it doesn't exist continue. The problem is that this function gives an error in the log if it does not find the id but in itself it is not a problem
            Last edited by dcriador; 05-07-2024, 08:51 AM.

            Comment


              #7
              Hello dcriador,

              You would need to use a print then to see what is changed from the sample, the sample is known to work normally and submit a single ATM until it is filled. The logic in the sample is a requirement to using ATM's due to how they are externally running from the strategy.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              52 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              130 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              70 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              44 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              48 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X