Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit target function

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

    Profit target function

    Hello,
    I have a problem with profit targets. I want the contract to close when it reaches the obtained target. But I do not want an automated order to be entered unless the strategy signals for it according to its original settings. What happens now is that the automated system buys or sells again, without waiting for the original signal of the strategy.
    So what I need is:
    • an original strategy signal i.e. at crossing SMA 1000
    • target price 200 pips
    • exit and wait for the next original strategy signal at crossing SMA 1000 again


    In the picture you see that the system enters short at the immediately next step, which is something that I don’t want.

    I would appreciate any possible help.
    Thank you.
    Attached Files

    #2
    Hello,

    Thank you for your note.

    The reason this occurs most likely is your EnterShort() or EnterLong() logic is still true thus it is still being called. Since Entries Per Direction is set to 1, as soon as you exit the 1 long position this allows the EnterLong()/Short() to execute again since the position is flat.

    To resolve this you would need to also have a flag, that you need to only call EnterLong() when this flag is set to true. Then when you EnterLong() set this flag to false. Therefor EnterLong will no longer be called continually. Also, you would need to set this flag back to True when your entry cinditions are valid again.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Brett, thank you for your answer,

      I understand from your answer that it is possible to achieve what I need. But I don’t understand exactly how to create the necessary conditions in Ninja and most importantly how to set the conditions for automated trading. Can you please give a step by step example?
      Thanks

      Comment


        #4
        giorgos, while we could not custom code this for you, the bool programming concept Brett brought up would work like the below -

        if (ConditionA and myBool)
        EnterLong()
        myBool = false;

        if (Condition B)
        myBool = true;

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        68 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        42 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        24 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        27 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        54 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X