Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

conditional plotting

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

    conditional plotting

    Hi,
    I'm new to NT script.I try to do the following.If current day range is equal or greater than 30 ticks, then DrawRegion the mid point. Compling is OK but doesn't plot to what I expected. It still plots from the beginning. Any advice will be much appreciated!

    mid.Set (Instrument.MasterInstrument.Round2TickSize((curre ntHigh+currentLow)/2));

    hhh.Set (currentHigh);
    lll.Set (currentLow);

    mid1.Set (mid[0]+TickSize*5);
    mid2.Set (mid[0]-TickSize*5);

    hhh1.Set (hhh[0]+TickSize*5);
    lll1.Set (lll[0]-TickSize*5);

    RR.Set (currentHigh-currentLow);
    R1.Set (RR[0]/TickSize);

    if (R1[0]>=30) DrawRegion("Reg1", CurrentBar, 0, mid1, mid2, Color.Transparent, Color.DarkRed,10);

    DrawRegion("Reg1", CurrentBar, 0, hhh, hhh1, Color.Transparent, Color.DarkGoldenrod,5);
    DrawRegion("Reg2", CurrentBar, 0, lll, lll1, Color.Transparent, Color.DarkGoldenrod,5);

    DrawText("MID1", false, mid1.ToString(), 0, mid1[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
    DrawText("MID2", false, mid2.ToString(), 0, mid2[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);

    DrawText("MID3", false, hhh.ToString(), 0, hhh[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
    DrawText("MID4", false, hhh1.ToString(), 0, hhh1[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
    DrawText("MID5", false, lll.ToString(), 0, lll[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
    DrawText("MID6", false, lll1.ToString(), 0, lll1[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
    Attached Files

    #2
    Hi K. SATO, and welcome to the forums,

    The syntax of DrawRegion() is seen at - http://www.ninjatrader-support.com/H...tml?DrawRegion

    First I see you use the Tag "Reg1" twice, which will override the previous one.

    When you pass in CurrentBar for startBarsAgo and 0 for endBarsAgo, this will color the region starting at the beginning of the chart, as soon as the condition is met.

    You will need to figure out a way to have your code logic identify (and record) when the condition has started, then use that (value you record - CurrentBar) for startBarsAgo.
    TimNinjaTrader Customer Service

    Comment


      #3
      There is an example (that I wrote) of how to use the DrawRegion() method in this link:
      http://www.ninjatrader-support2.com/...catid=1&sort=d

      Maybe that will help?

      Comment


        #4
        (1) Hi mountainclimber.Domo,domo,domo! After referring to your code,I got the thing up evevtually.Deeply appreaciated.

        (2) Hi NT support team.Strange phenomenons:
        (A) Log in problems:
        (a) My PC time is in sync,yet showing error 20051.

        (b) I've added 'Ninjatrader.exe' as a trusted file in my Firewall,yet showing error 10001 then 10004. Both (a) and (b) happened when I logged in to MIRUS-Zen FIRE.Sometimes (a), sometimes (b). But after a certain period of time(normally within 2-3 hours),logging in back to normal again.I'm using Ninja Version 6.5.10000.15

        (c)When I failed to log in MIRUS,I try to log in GAIN and everything was fine.

        (B) Chart display issue:
        (a)The following code works fine when I logged in to Gain.Logged in to MIRUS,sometimes it works and sometimes no display at all even after thirty minutes.Checked the Task Manager,showing "NO RESPONE" and CPU usage is as high as 70%.

        mid.Set (Instrument.MasterInstrument.Round2TickSize((curre ntHigh+currentLow)/2));

        hhh.Set (currentHigh);
        lll.Set (currentLow);

        mid1.Set (mid[0]+TickSize*5);
        mid2.Set (mid[0]-TickSize*5);

        hhh1.Set (hhh[0]+TickSize*5);
        lll1.Set (lll[0]-TickSize*5);

        RR.Set (currentHigh-currentLow);
        R1.Set (RR[0]/TickSize);

        if (R1[0]>=30)
        {
        DrawRegion("Reg1"+CurrentBar,1, 0, mid1, mid2, Color.Transparent, Color.DarkRed,10);
        }
        DrawRegion("Reg2", CurrentBar, 0, hhh, hhh1, Color.Transparent, Color.DarkGoldenrod,5);
        DrawRegion("Reg3", CurrentBar, 0, lll, lll1, Color.Transparent, Color.DarkGoldenrod,5);

        DrawText("MID1", false, mid1.ToString(), 0, mid1[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
        DrawText("MID2", false, mid2.ToString(), 0, mid2[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);

        DrawText("MID3", false, hhh.ToString(), 0, hhh[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
        DrawText("MID4", false, hhh1.ToString(), 0, hhh1[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
        DrawText("MID5", false, lll.ToString(), 0, lll[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
        DrawText("MID6", false, lll1.ToString(), 0, lll1[0] ,1, Color.Pink, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);

        DrawTextFixed("MID7", RR.ToString(), TextPosition.BottomRight, Color.White, largeFont, Color.Black, Color.Black,10);

        (b)Drawtext works with FDAX contract but not display properly with FOREX markets.

        (c)Is DrawRegion a RAM consumed function?What happens if I use it more than twenty in coding?

        (d)Shall I reinstall my NT?How to ensure I won't lose my custom indicators as I'm still pretty new to NT programming?If I select all custom indicators and export them to my own created folder,are these indicators exported to one single zip file which I can import later? Hope you understand my poor English for all the above.
        Attached Files
        Last edited by K. SATO; 05-02-2010, 12:57 PM.

        Comment


          #5
          k sato,

          You are welcome...

          The ZF issues may be due to a temporary server maintence issue... It happens to a lot of people for a couple hourse every day on Sunday. Not NT related, that I know of, it is ZF. But maybe the support staff have more info...

          Comment


            #6
            Hi NT support Team,
            May I have some feedback on second part (2) problems at #4? Thanks!

            Comment


              #7
              Hi K. SATO,

              Often times, this is resolved with a simple machine reboot.

              More info on these errors at - http://www.zen-fire.com/pages/demo/ninjafaq.html
              TimNinjaTrader Customer Service

              Comment


                #8
                Tim- did not know that link existed, thanks!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by georgeinharmony, Today, 12:06 AM
                2 responses
                12 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by Prisalice, Yesterday, 07:07 AM
                2 responses
                16 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Futurestrader00, Yesterday, 12:04 AM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Blairski, Yesterday, 11:26 PM
                0 responses
                10 views
                0 likes
                Last Post Blairski  
                Started by aligator, Yesterday, 02:38 PM
                0 responses
                10 views
                0 likes
                Last Post aligator  
                Working...
                X