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

output text on strategy optimiser chart

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

    output text on strategy optimiser chart

    Hi,

    I have been playing around modifying strategies in the strategy optimiser code and I want to check when my code logic lets a trade ride instead of closing out I am really struggling to get it to work,

    I have tried using DrawTextFixed() and DrawDiamond() (just in case text was the issue) and I get no (my) text on the chart and only a red diamond on the last bar

    I'm using imported daily data

    any one have any ideas where to go next

    thx

    ian

    #2
    Originally posted by hyena View Post
    Hi,

    I have been playing around modifying strategies in the strategy optimiser code and I want to check when my code logic lets a trade ride instead of closing out I am really struggling to get it to work,

    I have tried using DrawTextFixed() and DrawDiamond() (just in case text was the issue) and I get no (my) text on the chart and only a red diamond on the last bar

    I'm using imported daily data

    any one have any ideas where to go next

    thx

    ian
    Not without seeing the errant code.

    Comment


      #3
      Thanks koganam - Ian could you share the code snippets you used? If you apply the same strategy on a chart - any other behavior seen then?

      Thanks,
      BertrandNinjaTrader Customer Service

      Comment


        #4
        hi,

        Sorry about this, i had googled around and was pretty certain the answer would have been a ninja restriction on putting text/symbols on to SA charts from within the strategy code :

        heres a snippet of the simple code ive been using to try get the text/symbols show (didnt keep the various iterations of trying to get text to show) before putting itim my working strategies

        -------------------------------------

        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
        CalculateOnBarClose = false;
        }
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
        if (CurrentBar < 1) return;
        if ((High[0]-Low[0]) >1)
        {
        DrawDiamond("tag1", true, 0, Low[0] - TickSize, Color.Red);
        }

        ---------------------------------------------------------------------

        Comment


          #5
          Originally posted by hyena View Post
          hi,

          Sorry about this, i had googled around and was pretty certain the answer would have been a ninja restriction on putting text/symbols on to SA charts from within the strategy code :

          heres a snippet of the simple code ive been using to try get the text/symbols show (didnt keep the various iterations of trying to get text to show) before putting itim my working strategies

          -------------------------------------

          /// This method is used to configure the strategy and is called once before any strategy method is called.
          /// </summary>
          protected override void Initialize()
          {
          CalculateOnBarClose = false;
          }
          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          if (CurrentBar < 1) return;
          if ((High[0]-Low[0]) >1)
          {
          DrawDiamond("tag1", true, 0, Low[0] - TickSize, Color.Red);
          }

          ---------------------------------------------------------------------
          Provided that your conditions are met that will draw EXACTLY one diamond on your chart, at the last position that met the conditions.

          That is because you are using a fixed tag, so every time that the diamond is drawn, it is drawing the same exact object, just at a different place.

          If you want to see all drawn objects, you need unique tags. The commonest method used in these parts is to concatenate the CurrentBar into the tag thus: "tagPrefix" + CurrentBar.To String(), as the CurrentBar is guaranteed to be uniquely mapped 1 to 1 to the chart bars.
          Last edited by koganam; 09-22-2011, 06:20 PM.

          Comment


            #6
            Hi guys,

            many thx .. had a bash and worked perfectly, for others benefit here are the lines i used to test it works with text and symbols (diamonds in this case) :

            n.b. the "-L-" is the text i had it print on top of particular bars that met the condition in the IF statement and the "L-ROLLOVER" is the tag name which can be anything


            DrawText("L_ROLLOVER"+ CurrentBar, "-L-", 0, High[0]+2, Color.Red);

            DrawDiamond("L_ROLLOVER"+ CurrentBar, true, 0, Low[0]-2, Color.Red);

            b.r.

            ian

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by knighty6508, 05-10-2024, 01:20 AM
            4 responses
            24 views
            0 likes
            Last Post knighty6508  
            Started by OllieFeraher, 05-09-2024, 11:14 AM
            6 responses
            19 views
            0 likes
            Last Post OllieFeraher  
            Started by PaulMohn, 05-02-2024, 06:59 PM
            2 responses
            43 views
            0 likes
            Last Post PaulMohn  
            Started by ETFVoyageur, Today, 02:10 AM
            0 responses
            11 views
            0 likes
            Last Post ETFVoyageur  
            Started by rayyyu12, Today, 12:47 AM
            0 responses
            8 views
            0 likes
            Last Post rayyyu12  
            Working...
            X