• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting strategy (for exits)

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

    Backtesting strategy (for exits)

    Hi,

    I was wondering if I could exit my long position when the channel hits the bar as per the graph. How should I write the code? Thanks in advance
    Attached Files

    #2
    Hello JT1230,

    Thanks for your post.

    You would need to compare a price level to the lower plot of the Donchian channel as the condition. You will need to decide if you want to compare the Low or the Close of the bar against the Donchian lower plot level.

    Here is an example:

    if (Close[0] <= DonchianChannel(14).Lower[0])
    {
    ExitLong();
    }
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rainbow47, Today, 06:10 AM
    0 responses
    3 views
    0 likes
    Last Post rainbow47  
    Started by stenberg98, Today, 04:53 AM
    2 responses
    7 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by wukefuha, Today, 03:20 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by mbcmbc, Yesterday, 10:12 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by fx.practic, Today, 03:44 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Marco  
    Working...
    X