Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom properties aren't available to edit

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

    Custom properties aren't available to edit

    Hello,

    I just implemented a custom strategy. I use some properties to customize on "Strategies" window by user. And when I implemented such properties in the script I can't see them on "Strategies" dialog.

    I've attached two examples:
    * in one - there are custom properties
    * on another - are not

    I copy/paste the source of code and nothing happened.
    Piece of code , where I've implemented properties:

    Code:
    	#region Money Management		
    	[Description("Max. risk in ticks")]
            [Category("Money Management")]
    		[Gui.Design.DisplayNameAttribute("Max. Risk")]
            public int MaxRisk
            {
                get { return maxRisk; }
                set { maxRisk = value; }
            }
    		
    		[Description("Use MM filter")]
            [Category("Money Management")]
    		[Gui.Design.DisplayNameAttribute("MM Filter")]
            public bool FilterMM
            {
                get { return filterMM; }
                set { filterMM = value; }
            }
    		
    		[Description("Set Trailing Algoritm")]
            [Category("Trailing")]
    		[Gui.Design.DisplayNameAttribute("Trailing Algoritm")]
            public AkTrailingAlgoritm TrailingAlgoritm
            {
                get { return this.trailingAlgoritm; }
                set { this.trailingAlgoritm = value; }
            }
    
    		#endregion
    		
    		#region Work Time
    
    		[Description("Use Work Time Filter")]
            [Category("Work Time")]
    		[Gui.Design.DisplayNameAttribute("Time Filter")]
            public bool FilterWorkTime
            {
                get { return filterWorkTime; }
                set { filterWorkTime = value; }
            }
    		
    		
    		#endregion
    How could I fix this issue?
    Thank you in advance!
    Attached Files

    #2
    Hello akushyn,

    Thank you for writing in.

    Rather than using the [Category()] attribute for your properties, use [GridCategory()].
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thank you for the quick reply. It was helpful and now works fine.

      Have another question...
      When I add the strategy to the chart , where let say 15 days of history loaded, I try to run"Strategy Performance" to see the end result, but nothing happend. No trades and no any statistic.

      What steps should I follow to run correctly "Strategy Performance" ?
      I've tried :
      * Historical
      * Historical & Real Time

      My custom strategy enabled on a chart and I use OnBarClose = true calculations in the strategy.

      Thank you!

      Comment


        #4
        Hello akushyn,

        I would suggest debugging your code to ensure that trades have, indeed, been made.

        In the strategy add prints that print the values of every variable used in every condition that places an order along with the time of that bar.

        This will print to the output window.

        Below I am providing a link to a video that demonstrates adding prints to a script to get further information about the behavior of the script.

        Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thank you , ZacharyG

          I am using debugging with print statements as well as its possible in ninjascript. The reason is why I asked the question is that, when I run the strategy in Market Reply in real time I have all trades I need.
          But when I run in the way I have described in the previous message - have no trades.

          I use EnterLongStopLimit & EnterShortStopLimit type of orders. May be it will help you to help me
          Last edited by akushyn; 07-22-2016, 03:04 PM.

          Comment


            #6
            Hello akushyn,

            There are discrepancies between running a strategy in real-time vs historically/backtest: https://ninjatrader.com/support/help...ime_vs_bac.htm

            Can you confirm that the conditions you have specified in your strategy are becoming true?

            Can you confirm that your stop limit orders are executing?

            You can set the TraceOrders property to true to help with debugging the behavior of your orders: http://ninjatrader.com/support/forum...63&postcount=1
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ZacharyG View Post
              Hello akushyn,

              There are discrepancies between running a strategy in real-time vs historically/backtest: https://ninjatrader.com/support/help...ime_vs_bac.htm

              Can you confirm that the conditions you have specified in your strategy are becoming true?

              Can you confirm that your stop limit orders are executing?

              You can set the TraceOrders property to true to help with debugging the behavior of your orders: http://ninjatrader.com/support/forum...63&postcount=1
              Thank you for the answer!

              I can confirm that the conditions are becoming true
              And I am not sure if limit orders is a good way to backtest.

              How would you recommend to adapt orders in the script to be sure to run on back test?

              Comment


                #8
                Hello akushyn,

                You are able to use limit orders in a backtest.

                Please ensure that your limit orders are actually filling.

                Note that a limit order will not trigger unless the market price is your specified price or better.

                You can check if your limit order is being execution with OnExecution(): https://ninjatrader.com/support/help...nexecution.htm

                Here is an example:
                Code:
                protected override void OnBarUpdate()
                {
                	EnterLongLimit(1, 2000, "MyLimitOrder");
                }
                
                protected override void OnExecution(IExecution execution)
                {
                	if (execution.Order != null && execution.Order.Name == "MyLimitOrder" && execution.Order.OrderState == OrderState.Filled)
                		Print(execution.ToString());
                }
                Are your limit orders filling? Do you see any executions in the backtest results?
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  Hello and thank you again for the answer!

                  I've executed backtest for last week period with Print() statements as you recomended and the Output was empty, except enabling the strategy
                  Code:
                  **NT** Enabling NinjaScript strategy 'akFZRStrategy/4062bdfe80df47758d9d6075069d0d47' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=True MaxRestarts=4 in 5 minutes
                  And then, I've downloaded the replay data and run in "real time" and got a lot of Print statements of "PlaceOrder()".

                  Code:
                  **NT** Enabling NinjaScript strategy 'akFZRStrategy/e57f7164225e45fbb2bdb3149f437307' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=True MaxRestarts=4 in 5 minutes
                  20.07.2016 8:27:02 Entered internal PlaceOrder() method at 20.07.2016 8:27:02: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1331,9 SignalName='enter.short.order.name' FromEntrySignal=''
                  20.07.2016 8:30:02 Entered internal PlaceOrder() method at 20.07.2016 8:30:02: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1332,4 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Execution='d070d68b61cc42fd9220cb9b0822295f' Instrument='GC 08-16' Account='Replay101' Name='enter.short.order.name' Exchange=Default Price=1331,9 Quantity=1 Market position=Short Commission=0 Order='339bb3a0bfc04a1c83874da04aa3e867' Time='20.07.2016 8:30:02'
                  20.07.2016 8:55:00 Entered internal PlaceOrder() method at 20.07.2016 8:55:00: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1331,7 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  20.07.2016 8:55:00 Amended matching order: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1331,7 SignalName=exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Move exitShortStopOrder, new StopPrice: 1331,7
                  20.07.2016 9:02:01 Entered internal PlaceOrder() method at 20.07.2016 9:02:01: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1330,6 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  20.07.2016 9:02:01 Amended matching order: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1330,6 SignalName=exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Move exitShortStopOrder, new StopPrice: 1330,6
                  20.07.2016 9:32:02 Entered internal PlaceOrder() method at 20.07.2016 9:32:02: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1329,4 SignalName='enter.short.order.name' FromEntrySignal=''
                  20.07.2016 9:37:19 Entered internal PlaceOrder() method at 20.07.2016 9:37:19: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1330,6 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Execution='be52f8ebab2f4bb4b5c46f9cc676c62c' Instrument='GC 08-16' Account='Replay101' Name='enter.short.order.name' Exchange=Default Price=1329,4 Quantity=1 Market position=Short Commission=0 Order='84d43cbc33c84b84bd3b57133e1a7378' Time='20.07.2016 9:37:19'
                  20.07.2016 10:07:00 Entered internal PlaceOrder() method at 20.07.2016 10:07:00: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1326,3 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  20.07.2016 10:07:00 Amended matching order: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1326,3 SignalName=exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Move exitShortStopOrder, new StopPrice: 1326,3
                  20.07.2016 10:11:00 Entered internal PlaceOrder() method at 20.07.2016 10:11:00: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1325,9 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  20.07.2016 10:11:00 Amended matching order: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1325,9 SignalName=exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Move exitShortStopOrder, new StopPrice: 1325,9
                  20.07.2016 11:08:06 Entered internal PlaceOrder() method at 20.07.2016 11:08:06: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1326,9 SignalName='enter.short.order.name' FromEntrySignal=''
                  20.07.2016 11:11:37 Entered internal PlaceOrder() method at 20.07.2016 11:11:37: BarsInProgress=0 Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1328,0 SignalName='exit.short.order.name' FromEntrySignal='enter.short.order.name'
                  Execution='d91cabed76f9428eb93a93831170adcd' Instrument='GC 08-16' Account='Replay101' Name='enter.short.order.name' Exchange=Default Price=1327 Quantity=1 Market position=Short Commission=0 Order='c12f69e4ea1f47c19b74adbc324993ac' Time='20.07.2016 11:11:37'
                  21.07.2016 8:49:01 Entered internal PlaceOrder() method at 21.07.2016 8:49:01: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1317,2 SignalName='enter.long.order.name' FromEntrySignal=''
                  21.07.2016 8:50:20 Entered internal PlaceOrder() method at 21.07.2016 8:50:20: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1316,1 SignalName='exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  Execution='f30d3ff4b0e64aaeb46741b73335bb4e' Instrument='GC 08-16' Account='Replay101' Name='enter.long.order.name' Exchange=Default Price=1317,2 Quantity=1 Market position=Long Commission=0 Order='7e9a071248f84d8bb0a74fc85e598cc3' Time='21.07.2016 8:50:20'
                  21.07.2016 10:24:00 Entered internal PlaceOrder() method at 21.07.2016 10:24:00: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1317,4 SignalName='exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  21.07.2016 10:24:00 Amended matching order: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1317,4 SignalName=exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  Move exitLongStopOrder, new StopPrice: 1317,4
                  21.07.2016 10:32:01 Entered internal PlaceOrder() method at 21.07.2016 10:32:01: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1317,6 SignalName='exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  21.07.2016 10:32:01 Amended matching order: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1317,6 SignalName=exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  Move exitLongStopOrder, new StopPrice: 1317,6
                  21.07.2016 11:27:05 Entered internal PlaceOrder() method at 21.07.2016 11:27:05: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1319,4 SignalName='enter.long.order.name' FromEntrySignal=''
                  Cancelled custom managed order at 21.07.2016 11:28:01: Order='865332a5302a44caab63f3e20cb98195/Replay101' Name='enter.long.order.name' State=Accepted Instrument='GC 08-16' Action=Buy Limit price=0 Stop price=1319,4 Quantity=1 Strategy='akFZRStrategy' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='865332a5302a44caab63f3e20cb98195' Gtd='01.12.2099 0:00:00'
                  21.07.2016 18:03:02 Entered internal PlaceOrder() method at 21.07.2016 18:03:02: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1323,7 SignalName='enter.long.order.name' FromEntrySignal=''
                  21.07.2016 18:17:55 Entered internal PlaceOrder() method at 21.07.2016 18:17:55: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1321,6 SignalName='exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  Execution='333f68281ec74e799aa663994d0068a6' Instrument='GC 08-16' Account='Replay101' Name='enter.long.order.name' Exchange=Default Price=1323,7 Quantity=1 Market position=Long Commission=0 Order='c34c5fe605e140f699c557d50cf821fb' Time='21.07.2016 18:17:55'
                  21.07.2016 18:39:00 Entered internal PlaceOrder() method at 21.07.2016 18:39:00: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1324,8 SignalName='exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  21.07.2016 18:39:00 Amended matching order: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1324,8 SignalName=exit.long.order.name' FromEntrySignal='enter.long.order.name'
                  Move exitLongStopOrder, new StopPrice: 1324,8
                  The line smth like "Move exitLongStopOrder, new StopPrice:...." means that StopOrder was modified to a new price into profit.

                  I am advanced experienced programmer, and I already finished to implement my strategy. (its more than 1500 lines of code with some custom indicators)
                  And for now , very important part is to optimize the input parameters. And for this I strongly need a backtest mechanism to work.

                  Thank you. Looking for your further assistance!

                  Comment


                    #10
                    My OnExecution method:

                    Code:
                            protected override void OnExecution(IExecution execution)
                            {
                    			/* We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
                    			which ensures your strategy has received the execution which is used for internal signal tracking. */
                    			
                    			if (enterLongOrder != null && enterLongOrder == execution.Order)
                    			{
                    				// enterLongOrder filled / partFilled / canceled without fill
                    				if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    				{
                    					try
                    					{
                    						switch (this.TrailingAlgoritm) 
                    						{
                    							case AkTrailingAlgoritm.ProfitTarget200:
                    							{
                    								// set stop loss
                    								// set take profit								
                    								exitLongStopOrder = ExitLongStop(0, true, execution.Order.Quantity, this.signal.Points.StopPrice - TickSize, EXIT_LONG_ORDER_NAME, ENTER_LONG_ORDER_NAME);
                    								exitLongLimitOrder = ExitLongLimit(0, true, execution.Order.Quantity, this.signal.Points.ProfitTarget, EXIT_LONG_LIMIT_ORDER_NAME, ENTER_LONG_ORDER_NAME);
                    								Print(execution.ToString());
                    								
                    								break;
                    							}
                    							case AkTrailingAlgoritm.FractalsMoving:
                    							{
                    								// set only stop order
                    								// exit on trailing below fractals
                    								exitLongStopOrder = ExitLongStop(0, true, execution.Order.Quantity, this.signal.Points.StopPrice - TickSize, EXIT_LONG_ORDER_NAME, ENTER_LONG_ORDER_NAME);
                    								Print(execution.ToString());
                    								
                    								break;
                    							}
                    						}
                    					}
                    					catch (Exception e) 
                    					{
                    						Print(e.ToString());
                    					}
                    					
                    					// Resets the enterLongOrder object to null after the order has been filled
                    					if (execution.Order.OrderState != OrderState.PartFilled)
                    					{
                    						enterLongOrder 	= null;
                    						this.signal.found = false;
                    						
                    						// update correction peak
                    						updateCorrectionPeak(AkPriorityDirrection.Long);
                    					}
                    				}
                    			}
                    
                    			if (enterShortOrder != null && enterShortOrder == execution.Order)
                    			{
                    				if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    				{
                    					try
                    					{
                    						switch (this.trailingAlgoritm) 
                    						{
                    							case AkTrailingAlgoritm.ProfitTarget200:
                    							{
                    								// set stop loss
                    								// set take profit
                    								exitShortStopOrder = ExitShortStop(0, true, execution.Order.Quantity, this.signal.Points.StopPrice + TickSize, EXIT_SHORT_ORDER_NAME, ENTER_SHORT_ORDER_NAME);
                    								exitShortLimitOrder = ExitShortLimit(0, true, execution.Order.Quantity, this.signal.Points.ProfitTarget, EXIT_SHORT_LIMIT_ORDER_NAME, ENTER_SHORT_ORDER_NAME);
                    								Print(execution.ToString());
                    								
                    								break;
                    							}
                    							case AkTrailingAlgoritm.FractalsMoving:
                    							{
                    								// set only stop order
                    								// exit on trailing above fractals
                    								exitShortStopOrder = ExitShortStop(0, true, execution.Order.Quantity, this.signal.Points.StopPrice + TickSize, EXIT_SHORT_ORDER_NAME, ENTER_SHORT_ORDER_NAME);
                    								Print(execution.ToString());	
                    								
                    								break;
                    							}
                    						}
                    						
                    					}
                    					catch (Exception e)
                    					{
                    						Print(e.ToString());
                    					}
                    					
                    					// Resets the enterShortOrder object to null after the order has been filled
                    					if (execution.Order.OrderState != OrderState.PartFilled)
                    					{
                    						enterShortOrder 	= null;
                    						this.signal.found = false;
                    						
                    						// update correction peak
                    						updateCorrectionPeak(AkPriorityDirrection.Short);					
                    					}
                    				}
                    			}
                    			
                    			// long stop order filled
                    			if (exitLongStopOrder != null && exitLongStopOrder == execution.Order)
                    			{
                    				if (execution.Order.OrderState == OrderState.Filled)
                    				{
                    					if (isImpulse(AkPriorityDirrection.Long))
                    						switchToImpulse(AkPriorityDirrection.Long);
                    					else
                    						switchToFlat();
                    						
                    					//updateCorrectionPeak(AkPriorityDirrection.Long);
                    					//updateImpulsePeak();
                    				}
                    			}
                    			
                    			// short stop order filled
                    			if (exitShortStopOrder != null && exitShortStopOrder == execution.Order)
                    			{
                    				if (execution.Order.OrderState == OrderState.Filled)
                    				{
                    					if (isImpulse(AkPriorityDirrection.Short))
                    						switchToImpulse(AkPriorityDirrection.Short);
                    					else
                    						switchToFlat();
                    
                    					//updateCorrectionPeak(AkPriorityDirrection.Short);
                    					//updateImpulsePeak();
                    				}
                    			}
                    			
                    			/*Print("\n---------------------------\n");
                    			Print("entry price: " + execution.Order.StopPrice);
                    			Print("order name: " + execution.Order.Name + "\n\n");
                    
                    			Print("stoploss: " + this.signal.Points.StopPrice);
                    			Print("takeprofit: " + this.signal.Points.ProfitTarget);
                    			Print("entry price: " + this.signal.Points.EntryPoint.Value);
                    			
                    			Print("last low: " + this.zigzag.LastLowPoint.Value.ToString());
                    			Print("last high: " + this.zigzag.LastHighPoint.Value.ToString());
                    			*/
                    		}

                    Comment


                      #11
                      Hello akushyn,

                      Thank you for your response.

                      Do you have any logic to prevent historical trading or updates to OnBarUpdate() for historical bars?
                      And example would be having the following at the beginning of OnBarUpdate():
                      Code:
                      if (Historical) return;

                      Comment


                        #12
                        Hello, Patrick and thank you for helping me!

                        Nope, I don't use any logic to prevent historical trading.
                        What I check is that CurrentBar more than 5 bars and more than BarsRequired.

                        I provide you OnBarUpdate and OnPositionUpdate logic below:
                        If you need more explanation , let me know

                        Code:
                                protected override void OnBarUpdate()
                        		{
                        			if(CurrentBar < 5 || CurrentBar < BarsRequired)
                        					return;
                        
                        			if (TimeToTrade)
                        			{
                        				this.signal.filteredByTime = false;
                        				BackColor = Color.Silver;
                        				RemoveDrawObject(AkNotify.WORK_TIME);
                        			}
                        			else
                        				this.signal.filteredByTime = true;
                        			
                        			if (!InPosition)
                        			{
                        				// calculate signal conditions
                        				calculate();
                        				
                        				string statusString = getStatus();
                        				DrawTextFixed(AkNotify.BOTTOM_STATUS, statusString, TextPosition.BottomLeft, Color.Blue, font, Color.Gray, Color.Yellow, 80);
                        
                        				// display Fibo when signal appear
                        				displayFibonacciRetracements();
                        				
                        				//-----------------------------------------------------
                        				// there is a long signal and no position
                        				if (Position.Account.Positions.Count == 0 && enterLongOrder == null && this.signal.found && this.signal.PriorityDirrection == AkPriorityDirrection.Long)
                        				{
                        					BarColorSeries[2] = Color.Lime;
                        
                        					// place buy order : fractal bar high + ticksize
                        					//enterLongOrder = EnterLongStopLimit(0,true, 1, this.signal.Points.EntryPoint.Value + 2 * TickSize, this.signal.Points.EntryPoint.Value + TickSize, ENTER_LONG_ORDER_NAME);
                        					enterLongOrder = EnterLongStop(0,true, 1, this.signal.Points.EntryPoint.Value + TickSize, ENTER_LONG_ORDER_NAME);
                        				} 
                        				else if (enterLongOrder != null && Low[0] < this.signal.Points.StopPrice) // continue correction --> cancel pending order
                        				{
                        					// cancel pending order
                        					CancelOrder(enterLongOrder);
                        					updateCorrectionPeak(AkPriorityDirrection.Long);
                        				}
                        
                        				//--------------------------------------------------------
                        				// there is short signal and no position
                        				if (Position.Account.Positions.Count == 0 && enterShortOrder == null && this.signal.found && this.signal.PriorityDirrection == AkPriorityDirrection.Short)
                        				{
                        					BarColorSeries[2] = Color.Lime;
                        
                        					// place sell order : fractal bar low - ticksize 
                        					//enterShortOrder =  EnterShortStopLimit(0, true, 1, this.signal.Points.EntryPoint.Value - 2 * TickSize, this.signal.Points.EntryPoint.Value - TickSize, ENTER_SHORT_ORDER_NAME);
                        					enterShortOrder =  EnterShortStop(0, true, 1, this.signal.Points.EntryPoint.Value - TickSize, ENTER_SHORT_ORDER_NAME);					
                        				} 
                        				
                        				// update peak of the correction => cancel pending order
                        				else if (enterShortOrder != null && High[0] > this.signal.Points.StopPrice)
                        				{
                        					// cancel pending order
                        					CancelOrder(enterShortOrder);
                        					updateCorrectionPeak(AkPriorityDirrection.Short);
                        				}
                        			} 
                        			else if (InPosition)
                        			{
                        				switch (Position.MarketPosition) 
                        				{
                        					case MarketPosition.Long:
                        					{
                        						switch (this.TrailingAlgoritm) 
                        						{
                        							case AkTrailingAlgoritm.FractalsMoving:
                        							{
                        								// if new down fractal appear
                        								if (AkFractalChecker.Down(Low, 2))
                        								{								
                        									// if fractal price above Position.AvgPrice && StopPrice and profit less then MinProfitInPips = move to breakeven
                        									// --> modify our exitLongStopOrder order to new StopPrice = Position.AvgPrice
                        									if (Low[2] - TickSize < Position.AvgPrice + this.position.MinProfitInPips * TickSize && Low[2] - TickSize >= Position.AvgPrice + this.position.MinPipsToBreakeven * TickSize && Low[2] - TickSize > this.exitLongStopOrder.StopPrice)
                        									{
                        										this.exitLongStopOrder = ExitLongStop(0, true, this.exitLongStopOrder.Quantity, Position.AvgPrice, EXIT_LONG_ORDER_NAME, ENTER_LONG_ORDER_NAME);							
                        										Print("Move exitLongStopOrder to BREAKEVEN, new StopPrice: " + this.exitLongStopOrder.StopPrice.ToString());
                        									}
                        									
                        									// --> modify our exitLongStopOrder order to new StopPrice = Low[2] - TickSize
                        									if (Low[2] - TickSize >= Position.AvgPrice + this.position.MinProfitInPips * TickSize && Low[2] - TickSize > this.exitLongStopOrder.StopPrice)
                        									{
                        										this.exitLongStopOrder = ExitLongStop(0, true, this.exitLongStopOrder.Quantity, Low[2] - TickSize, EXIT_LONG_ORDER_NAME, ENTER_LONG_ORDER_NAME);							
                        										Print("Move exitLongStopOrder, new StopPrice: " + this.exitLongStopOrder.StopPrice.ToString());
                        									}
                        								}							
                        								break;	
                        							}
                        						}
                        						
                        						break;
                        					}
                        					case MarketPosition.Short:
                        					{
                        						switch (this.TrailingAlgoritm) 
                        						{
                        							case AkTrailingAlgoritm.FractalsMoving:
                        							{
                        								// if new up fractal appear
                        								if (AkFractalChecker.Up(High, 2))
                        								{
                        									//Print ("New Up fractal: " + High[2].ToString());
                        									
                        									// if fractal price below Position.AvgPrice && StopPrice and profit less then MinProfitInPips = move to breakeven
                        									// --> modify our exitShortStopOrder order to new StopPrice = Position.AvgPrice
                        									if (Position.AvgPrice - (High[2] + TickSize) < this.position.MinProfitInPips * TickSize && Position.AvgPrice - (High[2] + TickSize) >= this.position.MinPipsToBreakeven * TickSize && High[2] + TickSize < this.exitShortStopOrder.StopPrice)
                        									{
                        										this.exitShortStopOrder = ExitShortStop(0, true, this.exitShortStopOrder.Quantity, Position.AvgPrice, EXIT_SHORT_ORDER_NAME, ENTER_SHORT_ORDER_NAME);
                        										Print("Move exitShortStopOrder to BREAKEVEN, new StopPrice: " + this.exitShortStopOrder.StopPrice.ToString());
                        									}
                        									
                        									if (Position.AvgPrice -  (High[2] + TickSize) >= this.position.MinProfitInPips * TickSize && High[2] + TickSize < this.exitShortStopOrder.StopPrice)
                        									{
                        										this.exitShortStopOrder = ExitShortStop(0, true, this.exitShortStopOrder.Quantity, High[2] + TickSize, EXIT_SHORT_ORDER_NAME, ENTER_SHORT_ORDER_NAME);
                        										Print("Move exitShortStopOrder, new StopPrice: " + this.exitShortStopOrder.StopPrice.ToString());
                        									}
                        									
                        								}
                        								
                        								break;	
                        							}
                        						}
                        						
                        						break;
                        					}
                        				}
                        			}
                        		}
                        		
                        	protected override void OnPositionUpdate(IPosition position)
                                {
                        			
                        			if (Position.MarketPosition == MarketPosition.Flat)
                        			{
                        				if (isImpulse(AkPriorityDirrection.Long))
                        						switchToImpulse(AkPriorityDirrection.Long);
                        
                        				else if (isImpulse(AkPriorityDirrection.Short))
                        					switchToImpulse(AkPriorityDirrection.Short);
                        				
                        				else
                        					switchToFlat();
                        			}
                                }

                        Comment


                          #13
                          Hello akushyn,

                          Thank you for your response.

                          Would we be able to test this on our end?

                          If so, you can send your strategy to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H - 1548020' in the subject line.
                          You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.

                          Comment


                            #14
                            Hello, Patrick

                            I've sent already the strategy zip file.

                            I want you to ask , if I have other questions, not related to the topic of "Custom properties aren't available to edit" , what is the better approach for you:
                            1. ask questions here
                            2. or create another post with new topic name?

                            Comment


                              #15
                              Hello akushyn,

                              Thank you for your post.

                              You can post a new thread or write a new email, this would be up to you. Posting on the forum allows other users to see the items brought up by other users and the steps and solutions found.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by GLFX005, Today, 03:23 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by nandhumca, Yesterday, 03:41 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by The_Sec, Yesterday, 03:37 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by vecnopus, Today, 06:15 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post vecnopus  
                              Working...
                              X