Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Suggestion for Indicator Developement

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

    Suggestion for Indicator Developement

    Hi i am planning to develop indicator that marks arrow up and prints trade text for signal, which is a bounce from EMA.

    I want to make sure that trade text signal will be appearing before bar actually closes, so i.e trade setup is developing get ready.


    Should Indicator be on price change or tick ?
    Should this be via indicator or strategy?
    Do we have an example of similar indicator?
    Last edited by tkaboris; 04-03-2023, 11:05 AM.

    #2
    Hello tkaboris,

    Thank you for your post.

    If you want an action, such as the trade text signal, to appear before the bar actually closes then you will need to calculate either OnPriceChange or OnEachTick. Typically, it is more resource-friendly to calculate OnPriceChange and OnEachTick should only be used if your script deals with volume values. For more details:This could be done via an indicator or strategy; if you are planning to only track EMA data, mark arrows, and draw text, then it could be done via an indicator. If you want it to also submit trades, then a strategy would be a better type of script to use.

    We have a reference sample that draws objects based on crossover conditions:You mentioned you would draw up arrows and text in your script. Please refer to the following help guide pages for more information:
    Please let us know if we may be of further assistance.

    Comment


      #3
      Hi I I wanted to print arrow and text only if bar closes in opposite directin(reverses) but when bar closed in the same direction it still kept the print. Is there a fix for it?

      protected override void OnBarUpdate()
      {

      if (CurrentBar < FastEMAPeriod || CurrentBar < SlowEMAPeriod || BarsInProgress != 0)
      return;

      string trade34B = "34B";
      if
      ((Close[1] < Open[1]) && (Close[2] < Open[2])
      && (Low[0] < Low[1]) && (Low[0] <= slowEMA[0]) && (Close[0] > slowEMA[0]))

      {
      Draw.ArrowUp(this, "uparrow"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.White);
      Draw.Text(this, "34BLong" + CurrentBar, true, trade34B, 0, Low[0] - (DisplayOffset * TickSize), 0, FontColor, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
      }
      }
      ​​Click image for larger version

Name:	image.png
Views:	162
Size:	866.9 KB
ID:	1244369

      Comment


        #4
        Hello tkaboris,

        Thank you for your reply.

        With candlesticks, if the Close is greater than the Open price, it is an up candle. If the Close is less than the Open, that is a down candle. If you are checking for a reverse, as in a switch from an up candle to a down candle or vice versa, you could check if the close of the previous candle was greater than the open of that candle and also if the close of the current candle is less than the open of the current candle (or the opposite). For example:

        if (Close[1] > Open[1] && Close[0] < Open[0])
        {
        // previous candle was up, current candle is down
        }
        if (Close[1] < Open[0] && Close[0] > Open[0])
        {
        // previous candle was down, current candle is up
        }

        I don't see this type of condition in your snippet; adding some sort of logic that checks for the reversal should help to address your concern.

        Please let us know if we may be of further assistance.

        Comment


          #5
          hi yes thank you I edidted my snippet, however my question was to how to not to print setup if candle didnt reverse. Right now, if candle starts reversing it prints out setup, but just before candle reverses it continues in the original direction leaving prints on the chart. in this case, setup wanted to develop but didnt develop and prints stayed on the chart. What needs to be done so that if reversal doesnt happen prints will disapear.?

          I tried to add bool setup but i cant figure it out how to print failed setup if current bar actually doesnt reverse..

          Code:
          private bool setup = false;
                  protected override void OnBarUpdate()
                  {    
          
                      if (CurrentBar < FastEMAPeriod || CurrentBar < SlowEMAPeriod || BarsInProgress != 0)
                          return;
          
                      string trade34B = "34B";
                      string failed34B = "F34B";
                      if                        
                      (Trade34B && setup ? (Close[1] < Open[1]) && (Close[2] < Open[2])                        
                      && (Low[0] < Low[1]) && (Low[0] <= slowEMA[0]) && (Close[0] > slowEMA[0])
                      && (Close[1] < Open[0] && Close[0] > Open[0]) : Close[0] > 0)                              
                      {
                          Draw.ArrowUp(this, "uparrow"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.White);
                          Draw.Text(this, "34BLong" + CurrentBar, true, trade34B, 0, Low[0] - (DisplayOffset * TickSize), 0, FontColor, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                          setup=true;
                      }
                      else if (Trade34B && setup==false)
                      {
                          Draw.Text(this, "Failed 34BLong" + CurrentBar, true, failed34B, 0, Low[0] - (DisplayOffset * TickSize), 0, FontColor, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
          
                      }
                  }​
          Last edited by tkaboris; 04-03-2023, 06:37 PM.

          Comment


            #6
            Ah I see you now edited & came up with the same boolean solution as me!

            your're not removing the arrow with RemoveDrawObject though:

            Code:
            bool ActiveUpArrow34B;
            protected override void OnBarUpdate()
            {
            if(IsFirstTickOfBar) ActiveUpArrow34B = false;
            
            if(.....)
            {
            //Draw Arrow & Text
            ActiveUpArrow34B = true;
            }
            else if(ActiveUpArrow34B){
            RemoveDrawObject("uparrow"+CurrentBar);
            ActiveUpArrow34B = false;
            }
            }
            -----------
            Also it's probably easier to use the same tag for the fail and succeed text, so they will overwrite each other.
            eg "SetupLabel"+CurrentBar
            Since you have different tag names then it's possible you could get 2 unique messages printed on the same bar.​​
            Last edited by anon84; 04-03-2023, 07:56 PM.

            Comment


              #7
              HI thanks for help if i do that else if statement it prints on everybar
              Click image for larger version

Name:	image.png
Views:	137
Size:	189.1 KB
ID:	1244583

              Comment


                #8
                private bool setup = false;
                protected override void OnBarUpdate()
                {

                if (CurrentBar < FastEMAPeriod || CurrentBar < SlowEMAPeriod || BarsInProgress != 0)
                return;

                string trade34B = "34B";
                string failed34B = "F34B";
                if
                (Trade34B && setup ? (Close[1] < Open[1]) && (Close[2] < Open[2])
                && (Low[0] < Low[1]) && (Low[0] <= slowEMA[0]) && (Close[0] > slowEMA[0])
                && (Close[1] < Open[0] && Close[0] > Open[0]) : Close[0] > 0)
                {
                Draw.ArrowUp(this, "uparrow"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.White);
                Draw.Text(this, "34BLong" + CurrentBar, true, trade34B, 0, Low[0] - (DisplayOffset * TickSize), 0, FontColor, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                setup=true;
                RemoveDrawObject(""Failed 34BLong""+CurrentBar);
                }
                else if (Trade34B && setup==false)
                {
                Draw.Text(this, "Failed 34BLong" + CurrentBar, true, failed34B, 0, Low[0] - (DisplayOffset * TickSize), 0, FontColor, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                RemoveDrawObject("uparrow"+CurrentBar);
                RemoveDrawObject("34BLong"+CurrentBar);

                }
                }​​
                eDanny
                NinjaTrader Ecosystem Vendor - Integrity Traders

                Comment


                  #9
                  Originally posted by tkaboris View Post
                  HI thanks for help if i do that else if statement it prints on everybar
                  Oh sorry about that!
                  hope you've solved it

                  Comment


                    #10
                    eDanny Thank you so much.

                    There is still a thing if you can help me with.
                    1. in historic data it plots correctly, only plots if bar closed bullish for buys signal. However in real time, it plots the object and if bar closed bearish it didnt remove object. As seen in thee image
                    below. It doesnt seem like failed 34B is printing though
                    I used eDanny code.. and attached indicator.

                    Also i was wondering what the logic would look like to have setup displayed as true with take profits in ticks?
                    setup is 34B if take profit reached, otherwise its failed 34B

                    (Trade34B && setup ? (Close[1] < Open[1]) && (Close[2] < Open[2])
                    && (Low[0] < Low[1]) && (Low[0] <= slowEMA[0]) && (Close[0] > slowEMA[0])
                    && (Close[1] < Open[0] && Close[0] > Open[0])
                    && (takeProfit >= 10 * TickSize)
                    : Close[0] > 0)​
                    Click image for larger version  Name:	image.png Views:	0 Size:	1.39 MB ID:	1244940
                    Last edited by tkaboris; 04-06-2023, 10:58 AM.

                    Comment


                      #11
                      There can be an issue with draw objects. It is safest to look back at the just closed bar (at fist tick of new bar) and run a test on it to see if the condition was true at bar close. If not, remove that draw object.
                      eDanny
                      NinjaTrader Ecosystem Vendor - Integrity Traders

                      Comment


                        #12
                        Ok. but what can be done to not to print setup if bar is not finished, like i mentioned in previous post? where it printed two setups side by side, first one is false and second is true?

                        Comment


                          #13
                          The first (false print) could have been true during the building of the bar. You can fix it intra bar by checking your bool and if it turns false, remove the draw object. As I noted, this may not work when a new bar comes along so you still need to test the previous bar at first tick to remove an erroneous object.
                          eDanny
                          NinjaTrader Ecosystem Vendor - Integrity Traders

                          Comment


                            #14
                            NinjaTrader_Emily


                            I am not completly sure how to check intrabar, to make sure signal will not stay printed if reversal bar not fully developed.
                            You can fix it intra bar by checking your bool and if it turns false, remove the draw object


                            Do you mean this?
                            if(IsFirstTickOfBar)&&
                            (Trade34B && setup = false ? (Close[1] < Open[1]) && (Close[2] < Open[2])
                            && (Low[0] < Low[1]) && (Low[0] <= slowEMA[0]) && (Close[0] > slowEMA[0])
                            && (Close[1] < Open[0] && Close[0] > Open[0]) : Close[0] > 0)
                            {

                            RemoveDrawObject("34BLong"+CurrentBar);
                            }​​
                            Last edited by tkaboris; 04-07-2023, 08:54 AM.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            606 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            353 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            105 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            560 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            561 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X