Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IOrder as a parameter

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

    IOrder as a parameter

    Is it possible to pass in a IOrder variable to a method that will create my entry? for example:
    protected override void OnBarUpdate()
    {
    EnterPosition(entryOrder_1, ENTRY_ONE, T1_positionQuantity);

    }


    private void EnterPosition(IOrder entryOrder, int entryTag, int positionQuantity)
    {
    if (entryOrder == null and some other condition)

    entryOrder = EnterLongLimit(0,true, positionQuantity, lowerBandEntry, "Long_" + entryTag);
    }

    The problem I am having is that once I have entered the position, my if-statement continues to always evaluate to true. In other words, my entryOrder(IOrder) variable remains null. However, if I print out the entryOrder.Token just after entering the position, then there is a value there. When the OnOrderUpdate fires, it fires with the same Token value. But if I print out the explicit variable that was passed into the EnterPosition method(entryOrder_1), then it is blank.

    Is it possible that the entryOrder_1 variable that is passed into EnterPosition method is passed "By Value" and not as an object reference??

    #2
    Not to worry, I solved the problem by ading the "ref" keyword to the parameters.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    47 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    15 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    21 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X