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 dcriador, Yesterday, 10:45 AM
      2 responses
      15 views
      0 likes
      Last Post dcriador  
      Started by SnailHorn, Yesterday, 10:49 PM
      1 response
      10 views
      0 likes
      Last Post SnailHorn  
      Started by manueldecastro, Yesterday, 10:26 AM
      4 responses
      21 views
      0 likes
      Last Post manueldecastro  
      Started by TraderIqbal, 10-20-2023, 10:12 AM
      2 responses
      120 views
      0 likes
      Last Post Funnywo
      by Funnywo
       
      Started by Creamers, 04-27-2024, 05:32 AM
      12 responses
      72 views
      0 likes
      Last Post Creamers  
      Working...
      X