Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy to Buy/Sell on Trend Change

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

    #16
    Hello Jesse,

    Below are the screenshots of the databox:
    Click image for larger version

Name:	image.png
Views:	130
Size:	180.1 KB
ID:	1314133Click image for larger version

Name:	image.png
Views:	126
Size:	185.4 KB
ID:	1314134
    Please let me know if its of any help and how can we utilize the data we need to achieve our goal?

    Thanks!
    Last edited by maaxk; 08-14-2024, 01:40 PM.

    Comment


      #17
      Hello maaxk,

      The databox is a button in the charts toolbar.

      Comment


        #18
        Hello Jesse,

        I have updated the previous response and added the databox screenshot there.

        Thanks!

        Comment


          #19
          Hello maaxk,

          You would need to open a new empty chart and only apply the single indicator that you wanted to use, I cant tell from the image which indicator you are trying to access. If you see plots for the single indicator that you wanted to use you should be able to select it in the strategy builder.

          Comment


            #20
            Hello Jesse,

            I did exactly as you directed and here is the chart and its databox:
            Click image for larger version  Name:	image.png Views:	0 Size:	256.1 KB ID:	1314151​New Chart -> Price based on: last -> Type: mdMaxPrimeObf -> Tick Trend: 2 -> Open Offset: 20 -> Tick Reversal: 30
            Load Data Based on: Bars -> Bars to Load: 500
            and the rest i left as it was. Then i opened the databox and took the screenshots.

            No of points in one bar is 5 top to bottom.
            No of points achieved after one bar is .50 so after two bars it would be 1 and after 4 it would be 2 and after 10 it would be 2 points like first bar is 19000 then on 10th bar it would be 19005.


            Now can you please guide me what to do. The goal is simple, track the bars as soon as it changes the color place the order, wait for a 5 more bars in that color and then close. then again wait for another color change and do the same and so on.

            Thanks!
            Last edited by maaxk; 08-14-2024, 02:53 PM.

            Comment


              #21
              Hello maaxk,

              The dataseries settings don't matter if you are trying to check if an indicator has plots so it can be used in the builder, you can use any chart. You just need to apply the single indicator to that chart so you can use the data box to see if it has plots. The image you provided has many indicators so I dont know which you are trying to check.

              If you are trying to make a condition based on bar data then you would need to make a price condition using the Close prices and bars ago. There is no way to detect a color change, you need to check if the price changed.

              Comment


                #22
                Hello Jesse,

                Thank you so much for your kind assistance, i think i am closer to the solution. I will do my homework and get back to you tomorrow.
                I am looking forward to further assistance from you.

                Thanks again!

                Comment


                  #23
                  Hello Jesse,

                  Thank you for your previous responses. I appreciate your patience. I have a few specific questions and clarifications regarding how to set up my strategy. I hope you can help me with these:
                  1. Mechanism for Bar Color Change:
                    • I understand that the bars on the chart change color based on certain conditions. Is there a built-in mechanism or indicator that causes this color change? If so, could you explain how this mechanism works or how it can be utilized in the strategy builder? I need to know how to detect these color changes programmatically.
                  2. Using Price Points for Strategy:
                    • Each bar represents 5 points. My goal is to place an order when the current bar is 2.5 points higher (or lower) than the previous bar and then wait for it to achieve an additional 0.5 points before placing the order. How can I set up this condition in the strategy builder? In other words, how can I programmatically detect when the price has increased by 2.5 points and then by 0.5 points more?
                  3. Order Placement and Closing Conditions:
                    • For an uptrend, my condition is to place an order when the current bar is 2.5 points higher than the previous bar and then wait for the price to increase by 0.5 points before placing the order. For a downtrend, the condition is similar but for a decrease. Once the price reaches 5 points (10 bars at 0.5 points each), I want to close the order. Can you explain how to implement these conditions in the strategy builder, considering both uptrends and downtrends?
                  4. Color-Based Conditions in Strategy Builder:
                    • There are two colors for the bars: green (price going up) and red (price going down). If there's a system or condition that decides the bar color based on price movement, why can't we use this color change as a condition directly in the strategy builder? Is there a way to programmatically use the color changes in the strategy to decide when to place or close orders?

                  I am trying to build a strategy that reacts to bar color changes and uses price movements to place and close orders. I would appreciate a step-by-step guide or any additional insights you can provide on how to achieve this in the strategy builder.

                  Looking forward to your guidance.

                  Comment


                    #24
                    Hello maaxk,

                    The custom modifications to the chart are a result of the scripts you applied, I wouldn't be able to detail how those items may work.

                    The builder is unable to use points as an offset, you can instead use ticks when creating price conditions. You would change from arithmetic offset to ticks and then enter a number of ticks to offset the price by that much.

                    For trends you would need to make price conditions that match that scenario, that is the example that I have provided earlier in this thread. There is not a way to use points so you would need to use either exact prices or use the ticks offset and offset prices by an amount of ticks in your conditions.

                    There is not a way to make a strategy based on color changes, strategies work based on numbers so you would need to make price conditions that match the changes you see in the chart. If your indicators do not provide specific signals that can be used to trigger trades then making a price condition would be the only way to achieve that goal otherwise.

                    Comment


                      #25
                      Hello Jesse,

                      I’d like to focus on how to utilize ticks for setting up my strategy. Here’s the breakdown of how ticks translate into points for my strategy:
                      • 1 point = 4 ticks
                      • 2.5 points = 10 ticks
                      • 0.5 points = 2 ticks
                      • 5 points = 20 ticks

                      Given this, how can I set up conditions in the strategy builder using ticks? Specifically:
                      1. Tracking Tick Movements:
                        • How can I programmatically detect when there has been a movement of 10 ticks (2.5 points) and then an additional 2 ticks (0.5 points) before placing an order?
                      2. Utilizing Ticks for Order Placement and Closing:
                        • How can I use tick-based movements to place an order and then close it once the price moves a total of 20 ticks (5 points)?

                      I need to understand how to leverage tick data to achieve this. Your guidance on how to effectively use tick data in the strategy builder will be greatly appreciated.

                      Comment


                        #26
                        Hello maaxk,

                        For both of these questions you need to make price conditions to do those type of tasks. As an example you can compare the close price against another price which has an offset applied to know when the close price goes past that calculated value.

                        Orders are actions which can be added to sets, when your sets condition becomes true you can submit an order.

                        An offset is not tick data, an offset uses math to increase or decrease a value as an offset from the original value. You can use the ticks offset to be able to enter a number of ticks and the price will be offset by the amount of price difference for the number of ticks that you entered.

                        Comment


                          #27
                          Hello Jesse,

                          Thank you for the clarification. I’d appreciate it if you could guide me through the steps to implement the following using price conditions and offsets:
                          1. Tracking Tick Movements with Price Conditions:
                            • I need to detect when the close price has moved 10 ticks (2.5 points) from a previous value and then an additional 2 ticks (0.5 points). How exactly can I set up a condition to compare the close price against another price with an offset applied? Could you provide a step-by-step guide on how to configure this in the strategy builder?
                          2. Order Placement and Closing Based on Tick Movements:
                            • Once the price has moved a total of 20 ticks (5 points), how can I set up a condition to close the order? Please explain how to use the offset and price conditions to implement this.

                          I’d appreciate a detailed, step-by-step explanation on how to apply these concepts in the strategy builder.

                          Thank you for your help.

                          Comment


                            #28
                            Hello maaxk

                            While I would not be able to walk you through each step of developing your strategy I can help to clarify how to use certain features in the builder, if you are trying something and it is not working you can post an image of the condition you made along with your questions. If you need step by step walkthrough assistance for creating a strategy we suggest reaching out to a third party educator who specializes in that type of assistance. If you would like information about third parties who can assist please let me know.

                            To make conditions that check if the close price passed another value you would need to make a price condition for that. For example you could compare the close price is greater than another price where you have applied an offset to the other price. Once the close price passes that value the condition would be true.

                            You can find details on how to make price conditions and also use offsets in the following two links.


                            Comment


                              #29
                              Hello Jesse,
                              I hope you are doing well.

                              Please review my code, it is placing an order but not in the right way. please if you can explain it to me where is the error and what conditions will i change to get what i wanted:

                              //This namespace holds Strategies in this folder and is required. Do not change it.
                              namespace NinjaTrader.NinjaScript.Strategies
                              {
                              public class Order8tt : Strategy
                              {
                              protected override void OnStateChange()
                              {
                              if (State == State.SetDefaults)
                              {
                              Description = @"Place and order when trend is transitioning and close after some points.";
                              Name = "Order8tt";
                              Calculate = Calculate.OnBarClose;
                              EntriesPerDirection = 1;
                              EntryHandling = EntryHandling.AllEntries;
                              IsExitOnSessionCloseStrategy = true;
                              ExitOnSessionCloseSeconds = 30;
                              IsFillLimitOnTouch = false;
                              MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                              OrderFillResolution = OrderFillResolution.Standard;
                              Slippage = 0;
                              StartBehavior = StartBehavior.WaitUntilFlat;
                              TimeInForce = TimeInForce.Gtc;
                              TraceOrders = false;
                              RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                              StopTargetHandling = StopTargetHandling.PerEntryExecution;
                              BarsRequiredToTrade = 20;
                              // Disable this property for performance gains in Strategy Analyzer optimizations
                              // See the Help Guide for additional information
                              IsInstantiatedOnEachOptimizationIteration = true;
                              }
                              else if (State == State.Configure)
                              {
                              AddDataSeries(Data.BarsPeriodType.Tick, 1);
                              SetProfitTarget(@"", CalculationMode.Ticks, 10);
                              SetStopLoss("", CalculationMode.Ticks, 15, true);
                              }
                              }

                              protected override void OnBarUpdate()
                              {
                              if (BarsInProgress != 0)
                              return;

                              if (CurrentBars[0] < 1)
                              return;

                              // Set 1
                              if (Close[0] > (High[1] + (30 * TickSize)) )
                              {
                              EnterLong(Convert.ToInt32(DefaultQuantity), "");
                              }

                              // Set 2
                              if (Close[0] < (Low[1] + (30 * TickSize)) )
                              {
                              EnterShort(Convert.ToInt32(DefaultQuantity), "");
                              }

                              }
                              }
                              }

                              My goal is simple see if the current bar is 30 ticks higher than the previous bar order a long trade buy trade, if the current bar is 30 ticks lower than the previous bar order a short trade, sell trade.

                              Thank!

                              Comment


                                #30
                                Hello maaxk,

                                Your code appears to be doing that, you are checking if the close is greater than the high of the previous bar plus 30 ticks and entering long. The second set checks if the close is less than the low of the previous bar minus 30 ticks.

                                I see that you are using targets so this will not specifically be just a reversal strategy, it also has the possibility to exit the trade between the conditions becoming true.

                                If you wanted to further understand why the conditions are becoming true when they are I would suggest using a Print to output the bar time and also the calculated value along with the close price, that lets you see the close price for each bar and the calculated high price to compare based on the bar times. Depending on the output you can modify the conditions if needed.

                                If you are still using the builder you can find a video that goes over how to use prints here: https://drive.google.com/file/d/1CCl...gEIwJKv6L/view

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                558 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                324 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                545 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                547 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X