Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

fairway

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

    fairway

    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 GoodenoughCrosstest : Strategy
    {
    private FisherTransform FisherTransform1;
    private TEMA TEMA1;
    private TEMA TEMA2;
    private TEMA TEMA3;
    private TEMA TEMA4;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "GoodenoughCrosstest";
    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;
    Cons = 1;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    FisherTransform1 = FisherTransform(Close, 10);
    TEMA1 = TEMA(Close, 8);
    TEMA2 = TEMA(Close, 55);
    TEMA3 = TEMA(Close, 8);
    TEMA4 = TEMA(Close, 55);
    TEMA1.Plots[0].Brush = Brushes.HotPink;
    TEMA2.Plots[0].Brush = Brushes.Lime;
    AddChartIndicator(TEMA1);
    AddChartIndicator(TEMA2);
    }
    }

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

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Position.MarketPosition == MarketPosition.Flat)
    && (State.Realtime == State.Realtime)
    && (CrossAbove(FisherTransform1, -2.75, 1)))
    {
    EnterLong(Convert.ToInt32(Cons), "");
    }

    // Set 2
    if ((Position.MarketPosition == MarketPosition.Long)
    // Condition group 1
    && ((CrossBelow(FisherTransform1, -1.25, 1))
    || (CrossBelow(TEMA1, TEMA2, 1))))
    {
    ExitLong(Convert.ToInt32(Position.Quantity), "", "");
    }

    // Set 3
    if ((Position.MarketPosition == MarketPosition.Flat)
    && (State.Realtime == State.Realtime)
    && (CrossBelow(FisherTransform1, 2.75, 1)))
    {
    EnterShort(Convert.ToInt32(Cons), "");
    }

    // Set 4
    if ((Position.MarketPosition == MarketPosition.Short)
    // Condition group 1
    && ((CrossAbove(FisherTransform1, 1.25, 1))
    || (CrossAbove(TEMA3, TEMA4, 1))))
    {
    ExitShort(Convert.ToInt32(Position.Quantity), "", "");
    }

    }

    region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Cons", Order=1, GroupName="Parameters")]
    public int Cons
    { get; set; }
    #endregion

    }
    }​

    #2
    Hello nissan200sx55,

    Did you have a question about this code?

    Comment


      #3
      Hello Jesse,
      I was wondering why when I unlocked the code some of the parts are missing. Like I had 3 conditions in my group1 in set 2 and 4 but on the code it is only showing 2 of the 3? Thank you.

      Comment


        #4
        Hello nissan200sx55,

        I would be unsure, do you have a specific example that you can provide where that happens? If you can recreate this in a new empty strategy please create a new strategy builder file, add the conditions and then export the strategy as a builder script. Then attach that to this post along with the steps to see the condition removed, if that is just to unlock it just specify that is the only step.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        612 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        355 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        561 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        564 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X