• 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

Execute when bar crosses SMA

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

    Execute when bar crosses SMA

    I know it's silly but how do I execute a buy to cover when it crosses 20 period SMA?
    Attached Files

    #2
    Hello JT1230,

    Thanks for your post.

    As you are using the Bollinger indicator it would make sense to use that as the comparison. You could code something like:

    if (Position.MarketPosition == MarketPosition.Short && Close[0] > = Bollinger(2, 20).Middle[0])
    {
    ExitShort();
    }

    You may want to change Close for High, depends on your needs,

    ExitShort: "Generates a buy to cover market order to exit a short position." Helpguide link: http://ninjatrader.com/support/helpG...?exitshort.htm
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by tvaughan4, 12-13-2019, 10:46 PM
    2 responses
    14 views
    0 likes
    Last Post tvaughan4  
    Started by digibob, 12-13-2019, 10:01 PM
    3 responses
    12 views
    0 likes
    Last Post digibob
    by digibob
     
    Started by ldissinger, Yesterday, 12:55 PM
    1 response
    15 views
    0 likes
    Last Post ldissinger  
    Started by pstrusi, Yesterday, 09:06 AM
    1 response
    27 views
    0 likes
    Last Post marcus2300  
    Started by vpzdcv, Yesterday, 02:31 AM
    0 responses
    13 views
    0 likes
    Last Post vpzdcv
    by vpzdcv
     
    Working...
    X