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

short-term S/R

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

    short-term S/R

    I'm trying to locate and store the highest Open among the last bearish bars, since I've seen that this highest Open is a pretty significant short-term resistance, especially in calm markets, or breakout point, when crossed especially in trendy markets (same thing for the opposite case of the lowest Open among the last bullish bars).
    This easy script of mine seems to work well, creating a signal whenever these short-term resistance and support levels are broken, but I fear it could not apply to any possible case.
    Could it be written better ?



    #2
    Sorry, this is the code:

    if
    (Close[0] > Open[0]) // bullish bar
    {
    SUPPORT = Open[0]; // old short-term support
    if (Open[0]<newSUPPORT || newSUPPORT==0)
    {
    newSUPPORT=Open[0];// new support
    }
    }

    if (Close[0] < Open[0]) // bearish bar
    {
    RESIST = -Open[0]; // old short-term resistance (negative to avoid problems with the very first occurence)
    if (Open[0]>newRESIST)
    {
    newRESIST=Open[0]; // new resistance
    }
    }

    //// Alerts:
    if (Open[0] < Close[0] && High[0] > Math.Abs (RESIST)) // broken resistance
    {
    ENTERsignal = -1;
    SUPPORT = Open[0]; RESIST = 0; // resets
    }

    if (Open[0] > Close[0] && Low[0] < SUPPORT) // broken support
    {
    ENTERsignal = 1;
    RESIST = -Open[0]; SUPPORT = 0; // resets
    }

    Last edited by AlexAlex; 12-22-2015, 05:00 AM.

    Comment


      #3
      Hello,

      Thank you for the question,

      I am not sure where I could assist on this question, are you running into a problem regarding the supplied code or is it not doing what you had intended?

      I would not be sure if this could be re created in a better way without knowing first the reason it needs to be modified.

      If it is not having any problems it could likely be left alone, otherwise if it just needs to account for additional conditions, it seems you are well on your way there but I would not necessarily have any suggestions to make it better.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by techgetgame, Yesterday, 11:42 PM
      0 responses
      8 views
      0 likes
      Last Post techgetgame  
      Started by sephichapdson, Yesterday, 11:36 PM
      0 responses
      2 views
      0 likes
      Last Post sephichapdson  
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,613 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Yesterday, 05:56 PM
      0 responses
      10 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      20 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Working...
      X