Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Three Bar Simple Moving Average Cross Over

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

    Three Bar Simple Moving Average Cross Over

    Hi, I am trying to get a purchase signal off of a Price Close three periods after a cross over of a 10 period Simple Moving Average (SMA).

    How would you construct this using the Strategy Builder Conditions Wizard ensuring that each of the past three periods have closed green after the cross over.

    Please see the images attached to this thread.

    Thank you.

    #2
    Hello stock_wizard_49,

    Thanks for your post and welcome to the NinjaTrader forums!

    One way to accomplish your goal would be to save the bar number where the cross condition occurs in one set and in another set check to see if the cross occurred 3 bars ago and check that the 3 previous bars Close[] is greater then the Open[] for each of the 3 bars.

    I've created an educational example that you can test with. It will show a gold vertical bar on each cross condition and then a blue vertical bar when there are 3 green bars after the cross.

    To accomplish the math of the current bars check, a custom int series is used called CrossUpEvent.
    In set 1 (the sequence of sets is important), there are no conditions so that on every bar update the previous bar of the CrossUpEvent series is updated to the current bar value.
    In set 2 is the cross condition and the actions are to save the CurrentBar (the bar where the cross occurred) into the custom series and to color the backpanel a yellow color.
    In set 3, the condition is checked to see if the CrossUpEvent + 3 is equal to the CurrentBar value (meaning 3 bars have passed since the last cross. Also that the Close is greater than the open for the last 3 bars. The action is to then color the backplane a blue.

    Here is a screenshot example:

    Click image for larger version

Name:	ExampleCrossThen3upbars.PNG
Views:	125
Size:	31.2 KB
ID:	1109184


    I've attached the educational example here: [ATTACH]n1109185[/ATTACH]


    Here is a basic guideline of how to Import NinjaScripts.

    To import NinjaScripts you will need the original .zip file.

    To Import
    1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
    2. From the Control Center window select the menu File> Utilities> Import NinjaScript
    3. Select the downloaded .zip file
    4. NinjaTrader will then confirm if the import has been successful.

    Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'


    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Protech, Today, 11:08 AM
    1 response
    19 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by guilhem, Today, 02:09 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by Hyper, Today, 12:20 PM
    1 response
    18 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by TurtleTrader, Today, 11:50 AM
    2 responses
    32 views
    0 likes
    Last Post TurtleTrader  
    Started by Ricam, Today, 12:21 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X