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 FrancisMorro, Today, 03:24 AM
          0 responses
          1 view
          0 likes
          Last Post FrancisMorro  
          Started by Segwin, 05-07-2018, 02:15 PM
          10 responses
          1,770 views
          0 likes
          Last Post Leafcutter  
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          31 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          944 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          11 views
          0 likes
          Last Post Max238
          by Max238
           
          Working...
          X