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

How to make a buy and sell signal?

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

    How to make a buy and sell signal?

    Hello

    i have the most fundamental question:

    How can i create a buy or sell signal from an event (several indicator parameters occured, not a single value reached a certain level)?

    I am using the zigzag indicator and in the indicator there is a line that i want to use as a sell trigger:

    if ((addHigh || updateHigh)

    at the moment i am outputting an alert

    Alert("sell now")

    but i would like to make this event accessible by a strategy in the wizard.

    I know that i would have to create a new plot inside the indicator and that the plot has to be something like -1 for sell and +1 for buy signal. But is not working.

    Can you sent me the actual lines of code that are required to make an event inside an indicator available in the strategy wizard?

    thank you very very very much

    #2
    I suggest create a dummy indicator via the Wizard with a plot name "TriggerEvent", then generate it. Look at the code generated in the Initialize() for this plot, copy to to your other indicator, then look in the Properties section and copy the TriggerEvent property to your other indicator.

    The TriggerEvent property will point to "Values[0]", you will need to change this in the indicator you copied to. Take a look at how many plots you had inititially. If only 1, then you this new one is the 2nd plot so change "Values[0]" to "Values[1]" for example.
    RayNinjaTrader Customer Service

    Comment


      #3
      How to test if everything went right?

      I added this strategy to test if the indicator outputs the correct buy and sell signals:

      if (_myfibtarget(DeviationType.Percent, 0.34, false, true).Plot0[0] == 1)
      {
      DrawDot("My dot" + CurrentBar, false, 0, Low[0], Color.Blue);
      }

      but I dont see any dots been drawn. So i guess the indicator is still wrong...

      In the indicator itself i am using Value [1]:
      public DataSeries Plot0
      {
      get { return Values[1]; }
      }

      because it is the 2nd plot
      Add(new Plot(Color.Blue, PlotStyle.Line, "_zigzag"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));

      on the bar update when my buy entry condition is there i am setting:

      Plot0.Set(1);

      Can you have a look at the attached indicator to see whats still missing (its the basic zigzag indicator with the additions you wanted me to add)


      Many thanks for helping me
      Attached Files

      Comment


        #4
        Likley Plot0 is never set to a value of 1.
        RayNinjaTrader Customer Service

        Comment


          #5
          how can i set the plot0 to true or false or 1 and 2

          how can i set the plot0 to true or false or 1 and 2 so i can access it from a strategy?

          i want when this event is activated in the zigzag indicator to set my buy signal:
          if ((addHigh || updateHigh))
          {

          Plot0.Set(1);



          Originally posted by NinjaTrader_Ray View Post
          Likley Plot0 is never set to a value of 1.

          Comment


            #6
            You must set it to a value. What I do is set to zero when false, 1 when true.

            Code:
            if (condition is true)
                Plot0.Set(1);
            else
                Plot0.Set(0);
            Your logic looks fine I am just saying that the setting value to 1 likely is never called.
            RayNinjaTrader Customer Service

            Comment


              #7
              zigzag indicator maybe not compatible with this kind of plots setting?

              when i do so only the first time the event happens my dot is drawn at the point where the signal occured.

              is it maybe in the nature of the zigzag indicator that it resets the on bar events all the time?


              Originally posted by NinjaTrader_Ray View Post
              You must set it to a value. What I do is set to zero when false, 1 when true.

              Code:
              if (condition is true)
                  Plot0.Set(1);
              else
                  Plot0.Set(0);
              Your logic looks fine I am just saying that the setting value to 1 likely is never called.

              Comment


                #8
                Unfortunately I don't know. From a logic perspective, what I have provided will work at a core level.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  is there maybe a simpler way to check if the zigzag indicator has currently the
                  addHigh or updateHigh set to true?

                  instead of adding a new Plot which would require for every indicator to have a special version with a plot function inside, for me the tradestation way to call
                  actual conditions of an indicator seams to me the more clever alternative...

                  at the moment i know that i can only check of values of dataseries of an indicator.

                  what would be the syntax to check for the above mentioned condition?

                  Originally posted by NinjaTrader_Ray View Post
                  Unfortunately I don't know. From a logic perspective, what I have provided will work at a core level.

                  Comment


                    #10
                    The only values accessible by our ZigZag indicator are bars again a high/low is made and the value of the high/low.

                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      missing example

                      on the zigzag help page i am missing an example to check if the last bar was a new zigzag point.

                      i tried checking for a new high with this command, but again no dots are drawn on the chart:

                      if (ZigZag(DeviationType.Percent, 0.34,true).HighBar(1, 1, 1) == 1)
                      {
                      DrawDot("My dot" + CurrentBar, false, 0, Low[0], Color.Blue);
                      }

                      Am i right that the statement in the bracket would output a 1 when on the last bar a new high was found?

                      High Bar
                      ZigZag(DeviationType deviationType, double deviationValue,dbool useHighLow).HighBar(int barsAgo, int instance, int lookBackPeriod)


                      Originally posted by NinjaTrader_Ray View Post
                      The only values accessible by our ZigZag indicator are bars again a high/low is made and the value of the high/low.

                      http://www.ninjatrader-support.com/H...V6/ZigZag.html
                      Attached Files

                      Comment


                        #12
                        I believe it should be:

                        (ZigZag(DeviationType.Percent, 0.34,true).HighBar(0, 0, 1) == 1)

                        however, I suggest just printing some values out, changing parameters to see what the output is so you gain an understanding of how it works.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          thank you my strategy finally is working

                          thank you

                          ZigZag(DeviationType.Percent, 0.34,true).HighBar(0, 1, 1) == 2

                          triggers the event that a new potential zigzag high is set, when combining this with other indicators its is a very good entry point for a short trade!


                          Originally posted by NinjaTrader_Ray View Post
                          I believe it should be:

                          (ZigZag(DeviationType.Percent, 0.34,true).HighBar(0, 0, 1) == 1)

                          however, I suggest just printing some values out, changing parameters to see what the output is so you gain an understanding of how it works.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Barry Milan, Yesterday, 10:35 PM
                          4 responses
                          15 views
                          0 likes
                          Last Post Barry Milan  
                          Started by DanielSanMartin, Yesterday, 02:37 PM
                          2 responses
                          13 views
                          0 likes
                          Last Post DanielSanMartin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          4 responses
                          12 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by terofs, Today, 04:18 PM
                          0 responses
                          11 views
                          0 likes
                          Last Post terofs
                          by terofs
                           
                          Started by nandhumca, Today, 03:41 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post nandhumca  
                          Working...
                          X