Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with MACD strategy

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

    #16
    What period type is selected for your chart(s)?
    * renko chart Brick Size 20



    Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

    *No error


    how can i program that
    I want to beable set the Qty size too
    I WANT WHEN THE diff line cross -0.02 a sell order is place followed with a trail and stop
    I WANT WHEN THE diff line cross 0.02 a buy order is place followed with a trail and stop

    Comment


      #17
      Hello julian nisbett,

      Thank you for your response.

      Please right click in your 20 Renko chart > select Data Series > set the 'Days to load' to a higher number > OK. Please test this by increasing the 'Days to load' to see if this adds the needed data.

      For the quantity you can set this through the UI by right clicking in your Chart > select Strategies > select your strategy (it must be disabled in order for you to configure it) > scroll down to 'Order properties' and then set the 'Set order quantity' option to 'Default quantity' and then set the 'Default quantity'.

      If you want to set the quantity in the code of the strategy you will need to unlock the code and review the Order Methods at the following link: https://ninjatrader.com/support/help...d_approach.htm

      You can also find information on using SetTrailStop() at the link above.

      Please let me know if you have any questions.

      Comment


        #18
        hi i'm trying to get this strategy to run but it's not can you tell me what i'm doing wrong please

        #region Using declarations
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Gui;
        using NinjaTrader.Gui.Chart;
        using NinjaTrader.Gui.SuperDom;
        using NinjaTrader.Gui.Tools;
        using NinjaTrader.Data;
        using NinjaTrader.NinjaScript;
        using NinjaTrader.Core.FloatingPoint;
        using NinjaTrader.NinjaScript.Indicators;
        using NinjaTrader.NinjaScript.DrawingTools;
        #endregion


        //This namespace holds Strategies in this folder and is required. Do not change it.
        namespace NinjaTrader.NinjaScript.Strategies
        {
        public class LongEntry0Cross : Strategy
        {
        private MACD MACD1;

        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = @"Original";
        Name = "LongEntry";
        Calculate = Calculate.OnEachTick;
        EntriesPerDirection = 1;
        EntryHandling = EntryHandling.AllEntries;
        IsExitOnSessionCloseStrategy = true;
        ExitOnSessionCloseSeconds = 30;
        IsFillLimitOnTouch = true;
        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)
        {
        SetProfitTarget("", CalculationMode.Ticks, 64);
        SetStopLoss("", CalculationMode.Ticks, 32, false);
        }
        else if (State == State.DataLoaded)
        {
        MACD1 = MACD(Close, 50, 100, 90);
        }
        }

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

        if (CurrentBars[0] < 1)
        return;

        // Enters Long on a 0 point cross
        if (CrossAbove(MACD1.Diff, 0, 1))
        {
        EnterLong(Convert.ToInt32(Position.Quantity), @"Long Zero");
        }

        // Resets the stop loss to the original value when all positions are closed
        if (Position.MarketPosition == MarketPosition.Flat)
        {
        SetStopLoss("", CalculationMode.Ticks, 32, false);
        }

        // If a long position is open, allow for stop loss modification to +5 ticks above entry else if (Position.MarketPosition == MarketPosition.Long)
        {
        // Once the price is greater or equal to entry price +20 ticks, set stop loss to +5 above entry price
        if (Close[0] > Position.AveragePrice + 20 * TickSize)
        {
        SetStopLoss("", CalculationMode.Ticks, Position.AveragePrice + 1 * TickSize, false);
        }
        }



        }
        }
        }

        Comment


          #19
          Hello julian nisbett,

          Thank you for your response.

          This strategy should be working properly. Please send me your log and trace files so that I may look into what occurred.

          You can do this by going to the Control Center-> Help-> Email Support. Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

          Please list 'ATTN: Patrick H' in the subject line and reference this thread in the body of the email.

          I look forward to assisting you further.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Fran888, 02-16-2024, 10:48 AM
          3 responses
          43 views
          0 likes
          Last Post Sam2515
          by Sam2515
           
          Started by martin70, 03-24-2023, 04:58 AM
          15 responses
          114 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by The_Sec, Today, 02:29 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by jeronymite, 04-12-2024, 04:26 PM
          2 responses
          31 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by Mindset, 05-06-2023, 09:03 PM
          10 responses
          265 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X