• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
      Patrick H.NinjaTrader Customer Service

      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.
          Patrick H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Botan626, Today, 04:43 AM
          0 responses
          4 views
          0 likes
          Last Post Botan626  
          Started by xsgex, Yesterday, 09:46 PM
          0 responses
          3 views
          0 likes
          Last Post xsgex
          by xsgex
           
          Started by Steve L, Yesterday, 09:36 PM
          0 responses
          6 views
          0 likes
          Last Post Steve L
          by Steve L
           
          Started by krugman25, Yesterday, 09:34 PM
          0 responses
          4 views
          0 likes
          Last Post krugman25  
          Started by indy73, Yesterday, 04:42 PM
          0 responses
          15 views
          0 likes
          Last Post indy73
          by indy73
           
          Working...
          X