Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

no result showing

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

    no result showing

    tring to build a strategy based on Bill William's indicator called Fractal. the are two plots in this indicator, plot1 indicates up fractal, the second one indicates down fractal.
    what's wrong with my code
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Current[0] > Fractals().Plot1[0]
    && High[1] < Fractals().Plot1[0]
    && Low[1] < Fractals().Plot1[0]
    && High[2] < Fractals().Plot1[0]
    && Low[2] < Fractals().Plot1[0]
    && High[3] < Fractals().Plot1[0]
    && Low[3] < Fractals().Plot1[0])
    {
    EnterLongStopLimit(DefaultQuantity, 0, 0, "");
    }
    Attached Files

    #2
    Hello,

    Thank you for the post.

    I wouldn't be sure from just the image but if there is no result, it is very likely the condition is not becoming true.

    Have you tried to Print the values you are using to see if the condition can become true on the bars you expect?

    If not, I would suggest trying to print something like the following:

    Code:
    protected override void OnBarUpdate()
    {
       Print("Time: " + Time[0] + " " + Current[0] + " > " +  Fractals().Plot1[0]);
    
       if (Current[0] > Fractals().Plot1[0]
    && High[1] < Fractals().Plot1[0]
    && Low[1] < Fractals().Plot1[0]
    && High[2] < Fractals().Plot1[0]
    && Low[2] < Fractals().Plot1[0]
    && High[3] < Fractals().Plot1[0]
    && Low[3] < Fractals().Plot1[0])
    {
    EnterLongStopLimit(DefaultQuantity, 0, 0, "");
    }
    
    }
    I only included one part of your condition in the print to keep this short, but you could add in each of the variables used in the condition to Print for each bar to know if the condition should be true or not. This is the first step I would suggest in locating the reason.



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      here is the code for fractal, am i using wrong name for Plots?

      #region Using declarations
      using System;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.ComponentModel;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.Design;
      #endregion

      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// Fractals
      /// </summary>

      [Description("Fractal Technical Indicator it is a series of at least five successive bars, with the highest HIGH in the middle, and two lower HIGHs on both sides. The reversing set is a series of at least five successive bars, with the lowest LOW in the middle, and two higher LOWs on both sides, which correlates to the sell fractal. The fractals are have High and Low values and are indicated with the up and down arrows.")]
      [Gui.Design.DisplayName("Fractals (by Bill Williams)")]
      public class Fractals : Indicator
      {
      #region Variables
      private int barcounter = 0;
      private Color upcolor = Color.Green;
      private Color downcolor = Color.Red;
      private System.Drawing.Font textFont;
      #endregion

      int tick_multiply = 0;
      protected override void Initialize()
      {


      Add(new Plot(downcolor, PlotStyle.Dot, "Low Pivot"));
      Add(new Plot(upcolor,PlotStyle.Dot,"High Pivot"));

      Plots[0].Pen.Width = 0.7F;
      Plots[1].Pen.Width = 0.7F;

      CalculateOnBarClose = false;
      Overlay = true;
      PriceTypeSupported = false;
      }

      protected override void OnBarUpdate()
      {

      if(CurrentBar <= 7)
      return;
      if(FirstTickOfBar)
      barcounter++;

      isLowPivot(2);
      isHighPivot(2);

      Comment


        #4
        Hello,

        Thank you for the reply.

        I am unable to see the plot names from what you have posted, but if this is the same indicator as: https://ninjatrader.com/support/foru...3&postcount=36

        The plot names would be plot0 and plot1.

        What was the result of Printing the values you use in the condition, were you able to see the values being used?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,265 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X