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.

    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;
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Working...
        X