im lost with arrays

 

well, im working in a expert that open a sell oder and a sell stop order at the same time (hedging) im stok in the part where im triying to store the order number of the sell order and the sell stop order in an array to make a function that when the sell order raise the take profit delete the SellStop order.

(Please excuse my english, im trying to translate my spanish. Let mi know if you can understand my problem)

   

input bla_bla_bla
...   
int ASO [][2];

int OnInit()
  { 
....

void OnTick()
  {              
   
    if (bla_bla_bla){         
            Sell(); 
        }       
    
  }
   
void Sell(){           
                
      MqlTradeRequest request={0};
      MqlTradeResult  result={0};
     
            request.action   =TRADE_ACTION_DEAL;                     
            request.symbol   =Symbol();                              
            request.volume   =LotSize;                              
            request.type     =ORDER_TYPE_SELL;                      
            request.price    =SymbolInfoDouble(Symbol(),SYMBOL_BID);
            request.deviation=5;                                     
            request.magic    =MagicNumber;                           
            request.tp       =(SymbolInfoDouble(Symbol(),SYMBOL_BID))-TakeProfit;                             

            ...

      SellStop(result.order);   
}      

void SellStop (ulong nordenSC) {

   MqlTradeRequest request={0};
   MqlTradeResult  result={0};

      request.action   =TRADE_ACTION_PENDING;                                 
      request.symbol   =Symbol();                                             
      request.volume   =LotSize;                                              
      request.deviation=slippage;                                             
      request.magic    =MagicNumber;                                          
      request.type     =ORDER_TYPE_SELL_STOP;                                 
      request.price    =SymbolInfoDouble(Symbol(),SYMBOL_BID)-EMP;                
      request.tp       =(SymbolInfoDouble(Symbol(),SYMBOL_BID)-EMP)-TKP;
            
// --->>> here i need to fill the array with the two order numbers (the sell order and the sellStop order) 
            
    ArrayFill(ASO,nordenSC,result.order); 

// im lost here, i need to fill the array to then read the array and see if a sell order raise the take profit to delete the sell stop order//       
            
       // please help!!     
                    
}   


 

That's one complex approach. why not just call the checking function when the tp is hit, which will then find the pending order and close it? This wouldn't work if you intend to use multiple orders, but a work-around would be, giving simultaneous orders same magic. Then when a trade hits a tp, find the other order with similar magic and delete it. 

Lol! Good luck though.

 
lehi.salazar:

well, im working in a expert that open a sell oder and a sell stop order at the same time (hedging) im stok in the part where im triying to store the order number of the sell order and the sell stop order in an array to make a function that when the sell order raise the take profit delete the SellStop order.

(Please excuse my english, im trying to translate my spanish. Let mi know if you can understand my problem)

   

Your logic makes no sense.

First of all opening a sell and a sell stop order is not "hedging".

If the sell stop order is between the sell price and take profit price, you can't delete the stop order as it will already have triggered before the TP was hit.

If the stop order entry is below the TP, the TP will always be hit before the stop order triggers, so what is the point of placing the stop order when it will always be deleted?