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

Problem Exiting a Trade Using My Indicator

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

    Problem Exiting a Trade Using My Indicator

    Being new to NinjaTrader I am starting to develop my own strategy but have come across a problem that I don't understand.

    I created my own indicator line (like a moving average) that I call "PN" and I want to use this PN value for determining whether to get in or out of a trade. When I am looking to enter a trade I want to Go Long when the current price is above the value of PN in the previous bar, which I call as PN[1]. Once I am Long the trade I want to exit when the current price drops below the PN in the previous bar PN[1].

    Although the strategy works alright for entering the trade it does not exit where I think it should. From the plot of the strategy, it looks like when I tell it to exit the trade when the price falls below PN[1], instead it will only exit the trade when the price eventually falls below the PN[1] where I entered the trade.

    Shouldn't PN[1] always refer to the previous bar value no matter what bar you are currently in? I am at a complete loss on why this is happening. Is there something I am missing or don't understand about my indicator or how it can be used? Any help would be appreciated.

    #2
    Hello LarryRay,

    Thanks for writing in.

    You understand correctly that using a bars ago index of 1 will give you the value of the previous bar.

    As for what is happening with the strategy's exit, I would not know without reviewing the code and taking debugging steps to print the values for the conditions used to fire your order logic.

    We have some debugging tips listed here:

    TraceOrders - https://ninjatrader.com/support/foru...ead.php?t=3627

    Debugging - https://ninjatrader.com/support/foru...ead.php?t=3418

    After adding prints to your order logic and enabling TraceOrders, what does the output window tell you about how the strategy exits?

    Market Replay is an excellent tool to reproduce occurrences that happened in realtime for debugging - https://ninjatrader.com/support/help...ket_replay.htm

    I'm happy to be of any further help.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,767 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    7 views
    0 likes
    Last Post rocketman7  
    Working...
    X