Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Checking previous position result

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

    Checking previous position result

    Hi,

    I would like to add to my strategy the following condition:

    < If the first position was a winning position do not open the second one. Open the third one only. >

    Is it possible to code it in such simple way? Please support.

    #2
    kucharek,

    I am happy to assist you.

    Could you please clarify? How is opening a third position different than opening a second one if the first one was winning?

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Yes, my explanation was quite lame.

      Example:
      Simple strategy - open long position when bar close in above 20-day donchian channel, exit long position after 2 days.

      1. First signal and position is opened. It closes 2 days later and gives 20 USD of profit. It is a winning trade.
      2. It takes a while and strategy gives next signal - but long position can't be opened because the previous trade was a winning trade.
      3. Following signal - this time strategy opens a long position because second signal was ignored (we assume that second signal was a loss or 0 USD trade)

      If it is still unclear please let me know.

      Comment


        #4
        kucharek, you can for example refer to GetProfitLoss() for this idea and then set a bool flag as needed to filter your entries - http://www.ninjatrader.com/support/h...profitloss.htm

        Using bool flags is a similiar concept to our user variables found in the Strategy Wizard, we have a reference sample for that approach here - http://www.ninjatrader.com/support/f...ad.php?t=15417

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        50 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        16 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X