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

Plot function into Strategy namespace

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

    Plot function into Strategy namespace

    Its possible use Plot function into Strategy namespace?
    How could i plot and image in an Strategy? Thank you.


    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max){
    
    graphics.DrawImage(myImg,0,0);
    
    }

    #2
    Hello,

    The Plot override is only for Indicator's so unfortuantely there is no way to directly use this inside of a strategy.

    The most common way around this would be to create an indicator that uses the Plot override and then Add that indicator using the Strategy. This would allow the indicator to plot the visuals as intended and the strategy sticks to its strategy logic.

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

    Comment


      #3
      Thank you very much again. All was correct, but now i need to change the image in my strategy.

      My indicator added 2 images but i need to alternate the images into the strategy.

      How can do it from strategy depending a variable?

      Thank you !

      Comment


        #4
        Hello,

        Can you tell me, are you asking how to provide a value to the indicator to tell it when to change images or are you asking how to get a value from the indicator to change images in the strategy?

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

        Comment


          #5
          I want to load 2 images into my strategy and show alternatively in the same place in the chart
          Unfortunately I can not load an indicator outside the "Initialize" function

          Comment


            #6
            Hello,

            Thank you for the reply.

            I am not certain I understand.

            The strategy adds an Indicator which adds two images correct?

            If the indicator is already added to the chart and displays images, does the strategy need to add two completely different images than the indicator had used or are these the same images and need changed?

            Potentially I am just not understanding the concept, if you could provide an image of what the script currently does and what you want it to do that may help as well.

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

            Comment


              #7
              I need to show an image or other into a strategy chart depends a variable value while the strategy price are moving....
              Last edited by ninjo; 08-20-2016, 03:07 AM.

              Comment


                #8
                I want to load 2 images and hidde or show into the strategy chart several times depending a variable value.

                Some ideas? Thanks

                Comment


                  #9
                  Hello,

                  Thank you for the reply.

                  We had started discussing how to have a strategy Add a indicator so that you could use override void Plot because this is not available from a strategy.

                  If the indicator you are using is Drawing Images, and the Strategy has Added this indicator, are you asking how to toggle what image the indicator displays from the strategy? Again the strategy can not draw images so this is the only way I can interpret what you are asking, is this correct?

                  If so you would need to create a public Property in the indicator which you can see the SMA for an example. The Period property is a public int property.

                  You could copy this property into the indicator and then utilize that value as a switch.

                  The strategy would then call the indicator with an additional overload, so you may currently call the indicator as:

                  MyCustomIndicator()

                  After adding the property it would be like this:

                  MyCustomIndicator(1);

                  A 1 or 0 could be used to change image in the indicator as an example.

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

                  Comment


                    #10
                    Thank you Jesse, but the image not show when i call the indicator in the OnBarUpdate function without Add() method...

                    The image only show when the Strategy add the indicator in the Initialize function...
                    But i want to update the indicator in the onBarUpdate strategy function.

                    I attach the files !

                    Other idea?
                    Attached Files
                    Last edited by ninjo; 08-22-2016, 01:17 PM.

                    Comment


                      #11
                      if you download the .cs files and compile in NT7 you can test it.

                      The image files need to be copied in the folder: "C:\Users\Public\"

                      Anyone knows how could do it ?

                      Thank you

                      Comment


                        #12
                        Hello ninjo,

                        Thank you for your response.

                        You need to put the logic of the strategy into the indicator. If your strategy check a condition and the result is to change the image, then the indicator should have that logic as well so it can change it's image plot.

                        Comment


                          #13
                          Hello PatrickH, thanks !

                          I understand you but ,... How could send variable values in real time to the indicator from strategy?

                          Comment


                            #14
                            Hello,

                            I have composed a sample that changes the image used via the strategy. This uses the existing public property, you were just missing the part where you create a variable of the indicator and assign a value to the property.

                            Additionally I had changed the Path being used to the images as I do not use a public user account, instead I used the NinjaTrader users path which is the Documents/NinjaTrader 7 folder. The images are just renamed to 1 and 2.

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

                            Comment


                              #15
                              Thank you very much !

                              Good job Jesse, works perfectly

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              53 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              32 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X