• 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

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:	52
Size:	31.2 KB
ID:	1109184


    I've attached the educational example here: ExampleCrossthen3Upbars.zip


    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 WHICKED, Today, 01:01 PM
    0 responses
    3 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by polo0202, Today, 12:15 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_BrendanC  
    Started by GARZONJ, Today, 11:27 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by NtFan, Today, 11:08 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by anamaria0589, Today, 09:39 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Jermaine  
    Working...
    X