New at Programming, stuck with a crossover strat - NinjaTrader Programming | futures io social day trading
futures io futures trading


New at Programming, stuck with a crossover strat
Updated: Views / Replies:1,517 / 13
Created: by DeadCatBounced Attachments:0

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
 
Thread Tools Search this Thread
 

New at Programming, stuck with a crossover strat

  #11 (permalink)
Elite Member
Baltimore MD US
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
DeadCatBounced's Avatar
 
Posts: 283 since Apr 2013
Thanks: 1,507 given, 621 received

Thanks for your reply Tasker_182!

Yeah I have been working my way through the help file. It is a ton of information to wrap my head around but I am trying!

I have added print statements to my code so it looks like this:

 
Code
        {
            if (CrossAbove((GetCurrentAsk() + (Offset * TickSize)), SMA(SMAlookback), 1))
			{
				Print("LongCurrentAsk: "+GetCurrentAsk()+" (Offset+Tick): "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
				Print("Calculated value: "+(GetCurrentAsk() + (Offset * TickSize)));
                EnterShort();
			}
            else if (CrossBelow((GetCurrentAsk() + (Offsetneg * TickSize)), SMA(SMAlookback), 1))
			{
				Print("ShortCurrentAsk: "+GetCurrentAsk()+" (Offsetneg+Tick): "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
				Print("Calculated value: "+(GetCurrentAsk() + (Offsetneg * TickSize)));
                EnterLong();
			}
        }
When I look at the output window as the code works I get this:

 
Code
ShortCurrentAsk: 92.94 (Offsetneg+Tick): -0.05 SMA: 92.8932
Calculated value: 92.89
2013-06-04 3:37:38 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:38 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
ShortCurrentAsk: 92.94 (Offsetneg+Tick): -0.05 SMA: 92.8932
Calculated value: 92.89
2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
ShortCurrentAsk: 92.94 (Offsetneg+Tick): -0.05 SMA: 92.8932
Calculated value: 92.89
2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
ShortCurrentAsk: 92.94 (Offsetneg+Tick): -0.05 SMA: 92.8932
So in that instance the price was above the SMA, at 5 ticks above it went long(which is good!) the output window keeps coming up with this over and over again

 
Code
2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

Which would mean to me that it keeps getting an order spammed at it that it cannot fill. When in reality all I would like is for it to do nothing until the price moved to 5 ticks below the moving average and have it reverse and go short then.

So basically right now it will do the first entry correctly but it will not reverse for me! :/

Anyways I will keep at it. seems like its a fairly decent sized learning curve but hopefully worth it once I figure it out!

Reply With Quote
 
  #12 (permalink)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received


Trader Chris View Post
 
Code
Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'


Check what are the values for these properties of your strategy in the property grid.

You can change these values in your code as well (in Initialize() ):

 
Code
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;

Reply With Quote
The following user says Thank You to gregid for this post:
 
  #13 (permalink)
Elite Member
Baltimore MD US
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, NQ
 
DeadCatBounced's Avatar
 
Posts: 283 since Apr 2013
Thanks: 1,507 given, 621 received


I havent changed the entries per direction from the default setting which from the webinars I have seen I believe the default value is 1.

I didn't want to change that because at this time I only want can do the one contract at a time! :P

So because I never played with that variable I do not even see it at all in the initialized() area

Reply With Quote
 
  #14 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,859 since Jun 2009
Thanks: 480 given, 3,255 received

Avoid CrossAbove() and CrossBelow()

First of all, you are using CrossAbove() and CrossBelow() incorrectly. If you look at CrossAbove() for example...

CrossAbove()

You will see that the first parameter needs to be a DataSeries object, not a double. The expression

 
Code
GetCurrentAsk() + (Offset * TickSize)
evaluates to a double, not a DataSeries. I'm surprised your code even compiles! NT's syntactical leniency is the cause of your headaches.

Personally, I've had problems getting these cross methods to work for me sometimes, maybe I was using them incorrectly, but a long time ago I decided to never use them. Now I do something like "if x > y and x wasn't > y in the last bar" logic to determine crosses above.

So if I was to use the Close instead of the ask (not sure why you're using the asking price) it could be

 
Code
SMA sma = SMA(Lookback);
double smaNow = sma[0];
double smaLastBar = sma[1];
double priceNow = Close[0];
double priceLastBar = Close[1];

if (priceNow + (Offset * TickSize) > smaNow && priceLastBar + (Offset * TickSize) <= smaLastBar)
...then we have a cross above scenario

Reply With Quote
The following user says Thank You to shodson for this post:

Reply



futures io > > > > > New at Programming, stuck with a crossover strat

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Programming (programming without coding) LukeGeniol Platforms and Indicators 11 September 16th, 2016 01:49 PM
MTF Strat question.... Tanju23 Elite Automated NinjaTrader Trading 2 April 25th, 2012 03:42 AM
Pimp My Strat! MXASJ The Elite Circle 53 August 19th, 2011 02:44 PM
Stuck on FN key timmyb Tech Support 1 January 24th, 2011 02:52 PM
Anyone have a strat they would like ported to 7? ZTR NinjaTrader 1 February 22nd, 2010 11:33 AM


All times are GMT -4. The time now is 10:48 PM.

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-12-14 in 0.09 seconds with 19 queries on phoenix via your IP 54.90.207.75