fh: SetStopLossTicks ... is it to cancel yet unfilled orders ?
07.06.2020 15.19

Algorithmic Trading with NinjaTrader


Tried to read through Average.FillPrice etc., but not yet understand exact concept and process of this method.

  • Yuri Zolotarev
    07.06.2020 17:53

    Please read asking questions guidelines carefully before asking the questions. If you take your time and explain yourself good enough someone on this forum might pay you back by taking their time trying to help you. One of the most important guidelines is:

    "Let us know what your problem is in the most possible detail. This is not a chat, neither a support line, neither a friendly phone call! This is a community, please spend your time researching the question and trying to make the question clear to the public so people can help you.  Let us know what you have done to find out for yourself before asking, what problems did you face, where did you look, what did you find out, why didn't that work for you"

    Thank you for understanding! Let's keep the place healthy and initiative from all sides!

  • Frank
    07.06.2020 18:01

    ... pls if someone around who knows, let me know

  • Yuri Zolotarev
    07.06.2020 18:05

    _stop = ex.Order.AverageFillPrice + size;

    _stop - global variable that is used to store stop loss value

    ex -> this is an object that is passed by NinjaTrader into the OnExecutionUpdate method, when we put a dot after it we can extracts information about orders from it ex.Order.AverageFillPrice in this case will give us information about the fill price of the order. It is called average because if say you had 5 lots filled in an order by different prices due to slippage NinjaTrader will take an average from them and return it as the order fill price.

  • Frank
    07.06.2020 22:41

    k cool think got most of it, only:

    a) has SetStopOrders(false, ExitShortStopName) here not also be set to true, so in case of being in the market short i would true the corresponding SetStopOrders?

    b) what does the SetStopOrders(true, ExitLongStopName); exactly do ? Not sure if i got that right yet.

  • Yuri Zolotarev
    08.06.2020 09:47

    SetStopOrders is a method which sets stop orders. When you call a method you can pass parameters into the method. So you have a method called

    void SetStopOrders(bool isStopLong, string exitOrderName)

    This method has 2 parameters that you can pass into it and use inside it. In the example above SetStopOrders... is called from within SetStopLossTicks. In the first case it is called with isStopLong true and and in the second case it is called with isStopLong false. So, when these values arrive into the method we can see what type of order we are trying to set. In the first case we look if isStopLong is true and set the order for a long position and vice versa for if isStopLong is false.