• 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

  • JT1230
    started a topic Execute when bar crosses SMA

    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

  • NinjaTrader_PaulH
    replied
    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

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by ballboy11, Today, 01:04 PM
1 response
6 views
0 likes
Last Post NinjaTrader_PaulH  
Started by Linda1507, Today, 01:22 PM
1 response
6 views
0 likes
Last Post NinjaTrader_Kate  
Started by ntbone, Today, 12:15 PM
1 response
12 views
0 likes
Last Post NinjaTrader_Jesse  
Started by ballboy11, Today, 12:32 PM
2 responses
5 views
0 likes
Last Post ballboy11  
Started by brownsfan019, Today, 12:04 PM
1 response
6 views
0 likes
Last Post NinjaTrader_PatrickG  
Working...
X