Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Profit (and Loss) Targets question

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

    #46
    Eventually the trade mentioned above did close but only after it reached its 'PerTrade Profit' Target of +300.
    See screenshot and amended (and renamed) text file of print data.

    I don't want the trades to continue (or start) when the bool 'OKtoTrade' is in a False status. Is there a way to avoid that?
    Thanks,
    Ronnie
    Attached Files

    Comment


      #47
      Hello RonnieB,

      Thanks for your replies.

      I will try to answer all three of your latest posts here.

      Regarding post #44, "Here is the latest, is there any way to keep the losses closer to the target whilst still doing the calc on bar close?" I am unsure what you are specifically referring to, can you provide a one line example (target was X, actual exit was Y)?

      Regarding post #45, "Why is this still in a short trade when the Bool=False and the bar has closed multiple times in that state? Shouldn't the trade exit after just 1 bar close when the bool=false?" What would cause the trade to exit? As far as I know the bool in your strategy is used to prevent entries, not induce exits. If you want it to exit then you would need to add a set that checks to see if PNL is above/below your limits and checks to see if you are in a market positions and then to exit that position.

      Regarding post #46, "I don't want the trades to continue (or start) when the bool 'OKtoTrade' is in a False status. Is there a way to avoid that?" Is the bool preventing entries AFTER the PNL is above/below your limits? This should show in your print statements. Regarding exits, please see my reply to post 45.

      Paul H.NinjaTrader Customer Service

      Comment


        #48
        In a related issue, I have things set up (I think) to stop trading at the end of the trading day so I am not holding positions 'overnight'. I am on Mountain time (i.e. Denver time) but it appears that the strategy took a trade that would have me holding a position overnight. Am I wrong? ... or what can I do to be sure that my strategy setup is not holding overnight positions?

        Follows is the PRINT data:

        | EMA41 Time/date = 11/22/2019 2:34:02 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 0
        | EMA41 Time/date = 11/22/2019 2:34:24 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 0
        | EMA41 Time/date = 11/22/2019 2:35:21 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 0
        11/22/2019 2:35:55 PM Strategy 'RB43EMAxoverOUTPUT/183068452': Entered internal SubmitOrderManaged() method at 11/22/2019 2:35:55 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=2 LimitPrice=0 StopPrice=0 SignalName='XoverShort' FromEntrySignal=''
        |$| EMA43 Time/date= 11/22/2019 2:35:54 PM Set#2(short) OKtoTrade bool= True
        | EMA41 Time/date = 11/22/2019 2:35:54 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 0
        | EMA41 Time/date = 11/22/2019 2:36:33 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = -60.0000000000023
        | EMA41 Time/date = 11/22/2019 2:37:05 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = -19.999999999996
        | EMA41 Time/date = 11/22/2019 2:38:55 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 39.999999999992
        | EMA41 Time/date = 11/22/2019 2:40:00 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 19.999999999996
        | EMA41 Time/date = 11/22/2019 2:45:12 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 39.999999999992
        | EMA41 Time/date = 11/22/2019 2:50:00 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = 39.999999999992
        | EMA41 Time/date = 11/22/2019 2:52:08 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = -19.999999999996
        | EMA41 Time/date = 11/22/2019 2:57:38 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = -60.0000000000023
        | EMA41 Time/date = 11/22/2019 2:59:21 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 439.999999999998 | EMA41 PerTrade UNRealizedPNL = -79.9999999999983
        11/22/2019 2:59:30 PM CancelAllOrders: BarsInProgress=0
        11/22/2019 2:59:30 PM Strategy 'RB43EMAxoverOUTPUT/183068452': Entered internal SubmitOrderManaged() method at 11/22/2019 2:59:30 PM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=2 LimitPrice=0 StopPrice=0 SignalName='Exit on session close' FromEntrySignal=''
        | EMA41 Time/date = 11/22/2019 2:59:45 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 339.999999999989 | EMA41 PerTrade UNRealizedPNL = 0
        | EMA41 Time/date = 11/22/2019 2:59:58 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 339.999999999989 | EMA41 PerTrade UNRealizedPNL = 0
        11/22/2019 2:59:58 PM Strategy 'RB43EMAxoverOUTPUT/183068452': Entered internal SubmitOrderManaged() method at 11/22/2019 2:59:58 PM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=2 LimitPrice=0 StopPrice=0 SignalName='XoverLong' FromEntrySignal=''
        |$| EMA43 Time/date= 11/22/2019 2:59:58 PM Set#3(long) OKtoTrade bool= True
        | EMA41 Time/date = 11/22/2019 2:59:58 PM | EMA41 Bool OKtoTrade = True | EMA41 PerSession StopLossTarget = -499 | EMA41 PerSession RealizedPNL = 339.999999999989 | EMA41 PerTrade UNRealizedPNL = 0
        Attached Files
        Last edited by RonnieB; 11-22-2019, 05:20 PM.

        Comment


          #49
          Thanks Paul,
          I see your point that the bool is used to prevent entry of a trade but not causes an exit. I'll work on a set that has the bool status of False = and exit of any active trades (instead of relying on another calculation of the balance I think I'd use the bool status to trigger exits as well. Is that a wise method if indeed I do want any active trades to exit if the bool = false?

          I sure thought I saw the situation from the print statements the way I see them that even when the bool = false, new trades are entered by the strategy which is not what I wanted to see... I'll try to find a clear example for you if indeed it occurs.

          Regardless I'll work on adding a set that causes an exit of all trades if bool=false.

          Thanks for all your help getting this closer to what I am wanting!
          Ronnie

          Comment


            #50
            Hello RonnieB,

            This Jim, responding on behalf of Paul who is out of the office at this time.

            ExitOnSessionClose can be used to have the strategy exit before the session closes.

            IsExitOnSessionCloseStrategy - https://ninjatrader.com/support/help...sestrategy.htm

            Bools are variables that represent true/false and can be used to control how your logic flows. If you do not want your bool to control how the strategy exits, your exit conditions should not be controlled by the bool.

            If you are seeing new trades entered, this would mean that your logic is allowing the conditions to become true and call the order entry method. Debugging steps to print out the values used to evaluate the condition would be necessary to see why those conditions became true so you can better understand what modifications would be needed to prevent the condition from becoming true when you do not expect it to be true. For example, if you are using a bool to control when you enter, is the bool true or false when you expect it to be? If not, review of your logic will be necessary so the bool is set to true when it needs to, and it is set back to false when it needs to.

            Please let us know if we can be of further assistance.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Perr0Grande, Today, 08:16 PM
            0 responses
            2 views
            0 likes
            Last Post Perr0Grande  
            Started by elderan, Today, 08:03 PM
            0 responses
            3 views
            0 likes
            Last Post elderan
            by elderan
             
            Started by algospoke, Today, 06:40 PM
            0 responses
            10 views
            0 likes
            Last Post algospoke  
            Started by maybeimnotrader, Today, 05:46 PM
            0 responses
            9 views
            0 likes
            Last Post maybeimnotrader  
            Started by quantismo, Today, 05:13 PM
            0 responses
            7 views
            0 likes
            Last Post quantismo  
            Working...
            X