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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    56 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X