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

Find Double Tops from the current bar

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

    Find Double Tops from the current bar

    Hi,

    I took parts from the Ninja PA indicator and rewrote them to find DTs/DBs. The original finds them only in hindsight (after the completion of the most recent swing) and not all of them (only one swing back).

    The code below is supposed to find all of them.
    Does anybody have an idea, why this is not working?
    It should test for DTs from the current bar (working bar) and draw text above that bar.

    It should work for live and historical data.

    These are my first steps with NT script. I´m coming from MQL and wrote several indicators including PA indis.

    if (CurrentBar < 70) return;

    double offset = 0.25;
    double toffset = 0.50;

    double curhigh = High[CurrentBar];
    for (int i = 1; i < 70; i++)
    {
    double prevhigh = 0;
    int barsback2 = Swing(1).SwingHighBar(2,i,70);
    if (barsback2 == -1) break;
    prevhigh = Swing(1).SwingHigh[barsback2];
    if (prevhigh > curhigh + offset) break;
    if (curhigh <= prevhigh + offset && curhigh >= prevhigh - offset)
    {
    DrawText("DT"+CurrentBar,"DT",0, High[CurrentBar] + toffset, Color.Peru);
    break;
    }
    }
    Last edited by td_910; 12-17-2011, 05:28 AM.

    #2
    works now

    mixed up CurrentBar with the relative addressing from the "other end"

    see below

    private double curhigh, prevhigh;
    private int barsback;

    curhigh = High[0];

    for (int i = 1; i < 70; i++)
    {
    prevhigh = 0;
    barsback = Swing(1).SwingHighBar(0,i,70);
    if (barsback < 2) break;
    prevhigh = Swing(1).SwingHigh[barsback];
    if (prevhigh > curhigh + offset) break;
    if (curhigh <= prevhigh + offset && curhigh >= prevhigh - offset)
    {
    DrawText("DT"+CurrentBar,"DT",0, High[0] + toffset, Color.Peru);
    break;
    }
    }

    Comment


      #3
      td_910

      I am happy you have resolved your issue.

      Please don't hesitate to contact us should you require additional assistance.
      Adam P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by helpwanted, Today, 03:06 AM
      2 responses
      21 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by DayTradingDEMON, Today, 09:28 AM
      0 responses
      2 views
      0 likes
      Last Post DayTradingDEMON  
      Started by navyguy06, Today, 09:28 AM
      0 responses
      2 views
      0 likes
      Last Post navyguy06  
      Started by rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      77 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      8 responses
      31 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X