Combining a breakeven trigger then trailing the stop to completion
18.10.2020 18.02

Creating Flexible Strategy Architecture in NinjaTrader 8

NinjaCoding friend

I currently have strategies where one will breakeven and split positions with 2 targets and another that will simply trail a stop. I am looking to combine them so that the remaining position after target 1 will then get trailed.

Any help would be greatly appreciated. Both stops are triggered by OnExecutionUpdate and I'm not sure how to structure it so they both are active. If I am even saying that properly, I am new to this. Understand what I am looking at, but am not sure how to create what I am looking for.

  • Yuri Zolotarev
    18.10.2020 20:22

    1) Set 2 GTC profit orders in the OnExecutionUpdate

    2) First set 1 stop order in the OnExectuionUpdate

    3) Identify when profit order 1 is hit by execution.Order.Name and when that occurs start your trail. You have various design options here:

    - let you strategy know that profit target 1 has been hit by rising a bool flag here

    - let your strategy know that profit target has been hit simply by looking at how many lots you have left in your position

    4) Following on from here you then trail on every OnBarUpdate event.

    Hope this helps.

  • NinjaCoding friend
    18.10.2020 23:00

    Can you show me the appropriate syntax to attach the trail order to an indicator?

  • Yuri Zolotarev
    18.10.2020 23:07

    You should be able to find some examples in this course

  • NinjaCoding friend
    26.10.2020 02:37

    In using your Architect example I was able to make some adjustments in the Entry module by adding a few more conditions. I have completed the code and it complied without errors, however, for some reason I am only getting short entries? Nothing was changed in the Entry Engine so I am not sure how to begin debugging this error.