Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Possible Crossover Alert

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

    Possible Crossover Alert

    Hello,

    I have a simple strategy based on 2 simple moving average crossover
    Let say we are 1 bar before a possible crossover. Since the moving averages are based on the closing price..the closing price of this bar will be very important and will lead to a signal or not.
    Therefor i want to plot an alert message on the chart..something like
    "Crossover alert! If curent bar closing price will be greater/below value x.xx the moving average will cross and a position will be initiated at the openning price of the next bar."
    Basically i want to know before the bar close if the curent price of the bar will be enough to generate a crossover when the bar will be closed.
    Is this possible?
    Thank you.
    Last edited by 1800promote; 02-19-2009, 11:02 PM.

    #2
    Originally posted by 1800promote View Post
    Hello,

    I have a simple strategy based on 2 simple moving average crossover
    Let say we are 1 bar before a possible crossover. Since the moving averages are based on the closing price..the closing price of this bar will be very important and will lead to a signal or not.
    Therefor i want to plot an alert message on the chart..something like
    "Crossover alert! If curent bar closing price will be greater/below value x.xx the moving average will cross and a position will be initiated at the openning price of the next bar."
    Basically i want to know before the bar close if the curent price of the bar will be enough to generate a crossover when the bar will be closed.
    Is this possible?
    Thank you.
    It's possible with additional calculations in the script.

    Comment


      #3
      well...any guidance on how to do it?..or is too complicated to try to do it myself..

      Comment


        #4
        Originally posted by 1800promote View Post
        well...any guidance on how to do it?..or is too complicated to try to do it myself..
        OK. Let's use two SMA's SMA10 and SMA20.
        The approach would be like this:

        CalculateOnBarClose = false;

        if(SMA(10)[0] < SMA(20)[0] && Rising(SMA(10)))
        {
        double x = Close[0];

        while((SUM(Close, 9)[1] + x)/10 <= (SUM(Close, 19)[1] + x)/20)
        {
        x+=TickSize;
        }

        if (x - Close[0] <= 2*TickSize)
        {
        Print ("Hey, we are less than two ticks away from possible crossover");
        Print (" Be Prepared to Enter Long Position");
        }
        }

        Viceversa for oposite direction.

        I just give you an idea. I did not compile this code, I am writing it directly to the forum out of my head.

        If you want to use EMA or HMA or whatever MA you should use the appropriate calculation formulas.

        Hope it helps.

        roonius

        Comment


          #5
          thank you.will try it.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by PhillT, Today, 02:16 PM
          2 responses
          6 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by gentlebenthebear, Today, 01:30 AM
          2 responses
          14 views
          0 likes
          Last Post gentlebenthebear  
          Started by PaulMohn, Today, 12:36 PM
          2 responses
          17 views
          0 likes
          Last Post PaulMohn  
          Working...
          X