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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X