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

Strategy Not plotting

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

    Strategy Not plotting

    Hello,

    I created a strategy using the strategy builder..it compiled ok..

    But it won't plot on the charts... ( i did enable strategy for the chart it's on in the control center))

    It's just a simple one for me to test the functionality... I have another strategy I'm using and it's working fine.

    All it does it puts an up arrow when the 7 EMA is higher than the 14 EMA..


    Now I don't use this strategy to plot the EMA just to mark the above condition with upArrow.


    I use the default EMA to plot the EMA's on chart...

    Here is the code that the builder produced..

    public class EMAPlotTest : Strategy
    {
    private EMA EMA1;
    private EMA EMA2;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "EMAPlotTest";
    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;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    EMA1 = EMA(Close, 7);
    EMA2 = EMA(Close, 14);
    }
    }

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

    if (CurrentBars[0] < 0)
    return;

    // Set 1
    if (EMA1[0] > EMA2[0])
    {
    Draw.ArrowUp(this, @"EMAPlotTest Arrow up_1", false, 0, 0, Brushes.Lime);
    }

    }
    }

    I'm not sure on the reason why it won't plot? did the builder generate the wrong condition code? EMA1[0] > EMA2[0]


    Thanks
    Traderhawk

    #2
    Hello traderhawk,
    I believe its drawing the arrows but you're unable to see it on chart, so go to Drawing Objects & you can find the arrow. The issue here is that it will be drawn at 0 price level so it might not be visible as you've also set auto scale as false. You can change the double price and / or auto scale.
    Hope it helps!

    Comment


      #3
      Hello traderhawk,

      Thanks for your post.

      In addition to s.kinra's detail, you may want to consider creating a unique drawing tag for your draw objects so you have an object for each bar the condition becomes true. When the tag is kept the same the drawing object will be updated/replaced. Please see below.

      Drawing on a chart (making unique Drawing Objects) - https://ninjatrader.com/support/help...ToDrawOnAChart

      Also if you want to have an object drawn the first bar this condition is true, you may wish to consider using CrossAbove/CrossBelow rather than greater/less than.

      Creating Crossover conditions - https://ninjatrader.com/support/help...sOverCondition

      We look forward to assisting.
      JimNinjaTrader Customer Service

      Comment


        #4
        Thanks for your replies..S.kinra was right the objects where there just in the wrong location... I used a different approach with DrawUpArrow to to position the arrow just below the Bar.
        From a previous post..

        Draw.ArrowUp(this, @"DblGreenDblRed Arrow up_1" + Convert.ToString(CurrentBars[0]), false, 0, (Low[0] - (3 * TickSize)) , Brushes.Aquamarine);

        I'll check the Unique Drawing Objects ..thanks for the feedback..helping to speed up my learning curve.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by PaulMohn, Today, 03:49 AM
        0 responses
        3 views
        0 likes
        Last Post PaulMohn  
        Started by inanazsocial, Today, 01:15 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by rocketman7, Today, 02:12 AM
        0 responses
        10 views
        0 likes
        Last Post rocketman7  
        Started by dustydbayer, Today, 01:59 AM
        0 responses
        2 views
        0 likes
        Last Post dustydbayer  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        23 views
        0 likes
        Last Post trilliantrader  
        Working...
        X