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

Close trade if one of these conditions are met

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

    Close trade if one of these conditions are met

    I'm trying to develop a strategy and am using Strategy Builder. I have my Opening positions part working but need to get the closing part working.

    The position will close if one of these conditions are met

    1. Close position if the new bar is lower than the previous bar (Basically Green Bar then Red Bar) AND Volume is 1.5x greater than VolumeAverage
    Code:
    ((VOL1[0] * 1.5) > VOLMA1[0]))
    or

    2. Close position if the 2 last bar are lower than than the previous one (Basically Green Bar then Red Bar then Red Bar = Close).


    I don't think the strategy builder is able to do this so just needed some help.

    Thanks!
    Last edited by Ousher; 07-14-2020, 11:59 PM.

    #2
    Hello Ousher,

    Thanks for your post and welcome to the NinjaTrader forums!

    Yes, you can accomplish your goals with the Strategy Builder.

    A green bar can be defined as the Close price is greater than the Open price.

    A Red bar can be defined as the Close price is less than the Open price.

    You can specify which bar through the "bars ago" index where an index of [0] is the current bar, an index of [1] would be the bar before that, [2] the bar before that, etc.

    Here is a link to the help guide strategy builder example of accessing price data: https://ninjatrader.com/support/help...ataComparisons

    For the VOL indicator, you can "offset" the value which is how you can perform math on the volume value to achieve VOL1[0] * 1.5. Please see the strategy builder help guide example of offsetting values: https://ninjatrader.com/support/help...setAnItemValue

    To exit a position you can use the order methods of ExitLong() or ExitShort() found in the Order Management folder in the "do the following" section of a set.

    Here are the educational resource available on the strategy builder:
    Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
    Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
    Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Christopher_R, Today, 12:29 AM
    0 responses
    9 views
    0 likes
    Last Post Christopher_R  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    166 responses
    2,235 views
    0 likes
    Last Post sidlercom80  
    Started by thread, Yesterday, 11:58 PM
    0 responses
    3 views
    0 likes
    Last Post thread
    by thread
     
    Started by jclose, Yesterday, 09:37 PM
    0 responses
    8 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,415 views
    0 likes
    Last Post Traderontheroad  
    Working...
    X