• 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 DimaFridrich, Today, 01:54 AM
    0 responses
    6 views
    0 likes
    Last Post DimaFridrich  
    Started by ttodua, Today, 01:12 AM
    0 responses
    7 views
    0 likes
    Last Post ttodua
    by ttodua
     
    Started by NinjaCustomer, Today, 01:01 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by mohdqallaf, Today, 12:55 AM
    0 responses
    5 views
    0 likes
    Last Post mohdqallaf  
    Started by dvcpro4, Yesterday, 07:08 PM
    2 responses
    26 views
    0 likes
    Last Post NT-Roland  
    Working...
    X