BarsSinceEntryExecution isn't working. - NinjaTrader Programming | futures io social day trading
futures io futures trading


BarsSinceEntryExecution isn't working.
Updated: Views / Replies:1,464 / 51
Created: by alecsaccount Attachments:11

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 11  
 
Thread Tools Search this Thread
 

BarsSinceEntryExecution isn't working.

  #1 (permalink)
Elite Member
San Diego, California
 
Futures Experience: Beginner
Platform: NinjaTrader 8
Favorite Futures: Emini ES, EUR/USD
 
Posts: 64 since Dec 2016
Thanks: 229 given, 11 received

BarsSinceEntryExecution isn't working.

I want my strategy to exit when a long SMA crosses below a short SMA, and it's been less than 14 bars since entry.. So I used the strategy builder to add a set of conditions;

BarsSinceEntryExecution() < 14
SMA(X)[0] < SMA(Y)[0]

And now the summary is blank and there are no trades on the chart. There should be plenty of trades where X crossed below Y within 14 bars after entry, and even if there weren't, why would that change the results? What's wrong with what I did?

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,377 since Sep 2013
Thanks: 1,650 given, 3,521 received
Forum Reputation: Legendary


I think it would be good if you add some Print ("info....");
in your strategy, then you can follow and also Print the exact value that is returned ..

If it's -1, as per the manual, it means no entry is found
Which value does it return

Would probably also be helpful if you posted larger part of the code,
including how you constructed your if

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #4 (permalink)
Elite Member
San Diego, California
 
Futures Experience: Beginner
Platform: NinjaTrader 8
Favorite Futures: Emini ES, EUR/USD
 
Posts: 64 since Dec 2016
Thanks: 229 given, 11 received


rleplae View Post
I think it would be good if you add some Print ("info....");
in your strategy, then you can follow and also Print the exact value that is returned ..

If it's -1, as per the manual, it means no entry is found
Which value does it return

Would probably also be helpful if you posted larger part of the code,
including how you constructed your if

Sorry I missed this, it's weird. I checked my app 3 times that day and once the next day, and this thread didn't have any responses. :\

I don't know much about coding. I just made this in the strategy builder. Nothing happens when I click Run, unless I delete set 3. If I delete set 3 and compile, I get results.. I don't understand what could be causing this. Am I an idiot, and just using the indicator wrong?

update: so it still doesn't give results when I run it on high order fill resolution (1 tick), but it does give results on standard order fill resolution. this is useless to me, but I hope it helps you solve this problem. thanks so much for taking a look at this.

#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 Long : Strategy
{
private SMA SMA1;
private SMA SMA2;
private SMA SMA3;
private SMA SMA4;

protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "Long";
Calculate = Calculate.OnEachTick;
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)
{
SMA1 = SMA(30);
SMA2 = SMA(10);
SMA3 = SMA(60);
SMA4 = SMA(20);
}
}

protected override void OnBarUpdate()
{
if (CurrentBars[0] < 1)
return;

// Set 1
if ((Times[0][0].TimeOfDay >= new TimeSpan(6, 30, 0))
&& (Times[0][0].TimeOfDay < new TimeSpan(14, 30, 0))
&& (Position.MarketPosition == MarketPosition.Flat)
&& (SMA1[0] < SMA2[0]))
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if ((Position.MarketPosition == MarketPosition.Long)
&& (SMA3[0] > SMA4[0]))
{
ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
}
// Set 3
if ((SMA1[0] > SMA2[0])
&& (BarsSinceEntryExecution() <= 15))
{
ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
}

}
}
}

#region Wizard settings, neither change nor remove


Last edited by alecsaccount; March 13th, 2017 at 06:22 AM. Reason: update
Reply With Quote
 
  #5 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,377 since Sep 2013
Thanks: 1,650 given, 3,521 received
Forum Reputation: Legendary

If you open the output window and run it, does any error message appear ?

Reply With Quote
The following 2 users say Thank You to rleplae for this post:
 
  #6 (permalink)
Elite Member
San Diego, California
 
Futures Experience: Beginner
Platform: NinjaTrader 8
Favorite Futures: Emini ES, EUR/USD
 
Posts: 64 since Dec 2016
Thanks: 229 given, 11 received


rleplae View Post
If you open the output window and run it, does any error message appear ?

This is probably a very stupid question, but how do I open the output window?

wait, I found it.

Strategy 'Long': Error on calling 'OnBarUpdate' method on bar 14: Strategy 'Long/-1': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntryExecution() method in the context of a multi-time frame and instrument strategy.

Reply With Quote
 
  #7 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,377 since Sep 2013
Thanks: 1,650 given, 3,521 received
Forum Reputation: Legendary


alecsaccount View Post
This is probably a very stupid question, but how do I open the output window?

NinjaTrader -> tools -> output window

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #8 (permalink)
Elite Member
San Diego, California
 
Futures Experience: Beginner
Platform: NinjaTrader 8
Favorite Futures: Emini ES, EUR/USD
 
Posts: 64 since Dec 2016
Thanks: 229 given, 11 received


rleplae View Post
NinjaTrader -> tools -> output window

Strategy 'Long': Error on calling 'OnBarUpdate' method on bar 14: Strategy 'Long/-1': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntryExecution() method in the context of a multi-time frame and instrument strategy.

edit; I didn't see anything called 'BarsInProgress' on the list. Did I miss it?

Reply With Quote
 
  #9 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,377 since Sep 2013
Thanks: 1,650 given, 3,521 received
Forum Reputation: Legendary

If you have multiple time frames loaded on the chart, you need to select the timeframe you want this to work on

 
Code
 // Check which Bars object is calling the OnBarUpdate() method
    if (BarsInProgress == 0)
    {
        // A value of zero represents the primary Bars which is the ES 09-14
        // 1 minute chart.
        // Do something within the context of the 1 minute Bars here
    }
    else if (BarsInProgress == 1)
    {
        // A value of 1 represents the secondary 5 minute bars added in the Initialize()
        // Do something within the context of the 5 minute Bars
    }

Quoting 
BarsSinceEntryExecution()
BarsSinceEntryExecution(string signalName)



The following method signature should be used when working with multi-time frame and instrument strategies:



BarsSinceEntryExecution(int barsInProgressIndex, string signalName, int entryExecutionsAgo)

you have probably more than one instrument or dataseries loaded
if possible stick to one

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #10 (permalink)
Elite Member
San Diego, California
 
Futures Experience: Beginner
Platform: NinjaTrader 8
Favorite Futures: Emini ES, EUR/USD
 
Posts: 64 since Dec 2016
Thanks: 229 given, 11 received



rleplae View Post
If you have multiple time frames loaded on the chart, you need to select the timeframe you want this to work on

 
Code
 // Check which Bars object is calling the OnBarUpdate() method
    if (BarsInProgress == 0)
    {
        // A value of zero represents the primary Bars which is the ES 09-14
        // 1 minute chart.
        // Do something within the context of the 1 minute Bars here
    }
    else if (BarsInProgress == 1)
    {
        // A value of 1 represents the secondary 5 minute bars added in the Initialize()
        // Do something within the context of the 5 minute Bars
    }


you have probably more than one instrument or dataseries loaded
if possible stick to one

Again, I'm not writing this with the ninjascript editor; I'm using the strategy builder because I have no experience coding whatsoever. So what you just wrote means very little to me.

I don't understand. I've only been running one time frame, one instrument, one data series, as far as I know.

Backtest type: Standard

Strategy: Long

Instrument: ES 12-16

Price based on: Last

Type: Minute

Value: 15

Start date: 01/01/2016

End date: 12/31/2016

Trading hours: <Use instrument settings>

Break at EOD: true

Include commission: false

Maximum bars lookback: Infinite

Bars required to trade: 20

Entries per direction: 1

Entry handling: All entries

Exit on session close: false

Set order quantity: Strategy

Time in force: GTC

Reply With Quote

Reply



futures io > > > > > BarsSinceEntryExecution isn't working.

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

RandBots: AutoTrading Bots to diversify your trading

Oct 24
 

TopstepTrader: Profiting Without Risking Your Own Money

Oct 26

Building Open Source Indicators for NT8 w/Fat Tails @ Lizard Indicators

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Housing's Dilemma: When Having a Buyer Isn't Enough Quick Summary News and Current Events 0 February 22nd, 2012 03:10 PM
Hell Isn't So Bad? kbit Jokes 0 November 6th, 2011 06:32 PM
What is going on here (my strategy isn't producing orders) ???? jmejedi NinjaTrader Programming 5 June 7th, 2011 07:11 PM
Austerity Isn't Working; It's Time for a Plan B Quick Summary News and Current Events 0 June 6th, 2011 06:40 AM
Money itself isn't lost or made,..... George Psychology and Money Management 8 October 25th, 2010 02:10 PM


All times are GMT -4. The time now is 05:55 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-10-23 in 0.08 seconds with 19 queries on phoenix via your IP 54.167.250.64