Intense frustration moving to breakeven+1 in NinjaTrader strategy - NinjaTrader Programming | futures io social day trading
futures io futures trading


Intense frustration moving to breakeven+1 in NinjaTrader strategy
Updated: Views / Replies:841 / 5
Created: by DavidBodhi 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
 

Intense frustration moving to breakeven+1 in NinjaTrader strategy

  #1 (permalink)
Elite Member
Milwaukee, WI, USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: TF
 
DavidBodhi's Avatar
 
Posts: 47 since Oct 2014
Thanks: 2 given, 5 received

Intense frustration moving to breakeven+1 in NinjaTrader strategy

Hello, All.

I have been working on the following for untold hours, with overly vague feedback from NinjaTrader support and am intensely frustrated.

I have a strategy with a stoploss set in the Initialize() region. The entirety of that region is as follows:

protected override void Initialize()
{
SetStopLoss("", CalculationMode.Ticks, 10, false);
Add(SMA(21));
Add(ADX(14));
CalculateOnBarClose = false;
}

After positions are taken, I am monitoring maximum unrealized P/L in a variable called HighestUPnL. When that amount tops $40 (5 ticks in a $10/tick instrument, less transaction fee), I am TRYING to reset the stop to breakeven-1 tick.

The code intended to do so is as follows (I am just showing for short, though have another condition for long):

// Condition set 3
if (Position.MarketPosition == MarketPosition.Short
&& (HighestUPnL >= 40))
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice - 1 * TickSize, false);
}

Per NinjaTrader support, the code to move/set the stoploss is correct. However, when I run the strategy, I get errors, upon trying to take a position, that I can't place orders above (or below, depending whether short or long) the market.

If I comment out the line SetStopLoss("", CalculationMode.Price, Position.AvgPrice - 1 * TickSize, false); I get no errors. This, despite the fact that that code SHOULD only run when the position is open and unrealized P/L is above 40.

When the line is not commented out, the strategy will try to place an order (don't know if for entry or for the stop) MANY points away from the current price.

NT support is telling me it's due to a fast moving market, but no market consistently has transient orders at prices dozens of points away from current market value. They recommended I add, above the line to move the stop to breakeven+1, a line so I have:

// Condition set 3
if (Position.MarketPosition == MarketPosition.Short
&& (HighestUPnL >= 40))
{
if (Position.AvgPrice - 1 * TickSize < GetCurrentBid())
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice - 1 * TickSize, false);
}
}

When I do so, my strategy never places an order. (I did try to incorporate the GetCurrentBid() check incorporated into the one 'if', but never got that to even compile correctly.)

Despite all my emailing, the tech I am working with insists that the way I am trying to do this screws up because the market is moving too fast and my strategy is trying to place orders above/below inappropriately. However, when telling an ATM strategy to move my stop to breakeven+1, there's never any issue, so I think he's full of it. (I'm a neophyte, so I may be wrong.)

So, I have two issues:
1) My initial order fails if I have the code line below NOT commented out:

SetStopLoss("", CalculationMode.Price, Position.AvgPrice - 1 * TickSize, false);

2) I cannot get code that works to move my stop to 1 tick of profit.

I can't even get it to go to breakeven using:

SetStopLoss("", CalculationMode.Price, Position.AvgPrice, false);

Even leaving THAT not commented out makes my initial order fail.

I'm even considering forgetting the stoploss and simply placing limit orders where I want them, but writing the code for that looks even more daunting.

Does anyone have a clue what is going on with this, or have suggestions where to look or what to do? I am fairly desperate, right about now.



Last edited by DavidBodhi; May 27th, 2015 at 07:33 PM. Reason: Cuz I'm overly verbose.
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,489 since Sep 2013
Thanks: 1,704 given, 3,694 received
Forum Reputation: Legendary


This is a snippet of code form a robot i wrote, this is actually code that updates both
target and stop to new (higher levels). Use are you own risk
But it might help you forward...

 
Code
if (mylong == 1 && myturbo2OnOff == 1)
				{
					if (myCCI[0] > myCCI[1] && myCCI[0] > myCCIEMA34[0] && Close [0] > myEMA15[0])
					{ 
						if (High[0] >=  (mylongstop + ((double)myUPDATESTOP /myMULTIPLYER)) && mylongstop > mylongentry )
						{
						 mylongstop = High[0]-((double)8 / myMULTIPLYER);
						 mylongtarget = High [0]+((double)8/myMULTIPLYER);
						 DebugPrint ("Turbo 2 fired, new stop : "+mylongstop+", new target : "+mylongtarget);
 					     SetProfitTarget(CalculationMode.Price,mylongtarget);
					     SetStopLoss(CalculationMode.Price,mylongstop);
						 mynewstop++;
						}
					}
				}

Reply With Quote
 
  #4 (permalink)
Elite Member
Milwaukee, WI, USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: TF
 
DavidBodhi's Avatar
 
Posts: 47 since Oct 2014
Thanks: 2 given, 5 received

Re: Intense frustration moving to breakeven+1 in NinjaTrader strategy


rleplae View Post
This is a snippet of code form a robot i wrote, this is actually code that updates both
target and stop to new (higher levels). Use are you own risk
But it might help you forward...

 
Code
if (mylong == 1 && myturbo2OnOff == 1)
				{
					if (myCCI[0] > myCCI[1] && myCCI[0] > myCCIEMA34[0] && Close [0] > myEMA15[0])
					{ 
						if (High[0] >=  (mylongstop + ((double)myUPDATESTOP /myMULTIPLYER)) && mylongstop > mylongentry )
						{
						 mylongstop = High[0]-((double)8 / myMULTIPLYER);
						 mylongtarget = High [0]+((double)8/myMULTIPLYER);
						 DebugPrint ("Turbo 2 fired, new stop : "+mylongstop+", new target : "+mylongtarget);
 					     SetProfitTarget(CalculationMode.Price,mylongtarget);
					     SetStopLoss(CalculationMode.Price,mylongstop);
						 mynewstop++;
						}
					}
				}

Thanks, Becky. It looks pretty much like the code I already have, but I'll review it and see if I can extract insights from it.

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,489 since Sep 2013
Thanks: 1,704 given, 3,694 received
Forum Reputation: Legendary

In order to understand what you are trying to do and when

please create a logging :
current price
long or short
previous stop limit
stop limit you are trying to establish

As a sugestion
you might change your code into something :
if (long)
stop < current
SetStopLoss..
else
ExitLong..

if (shot)
stop > current
SetStopLoss
else
ExitShort

(be carefull with exitposition, close to stop's, you might have an OverFill ;-)
which is another headacht

Reply With Quote
 
  #6 (permalink)
Elite Member
Milwaukee, WI, USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: TF
 
DavidBodhi's Avatar
 
Posts: 47 since Oct 2014
Thanks: 2 given, 5 received

Re: Intense frustration moving to breakeven+1 in NinjaTrader strategy


rleplae View Post
In order to understand what you are trying to do and when

please create a logging :
current price
long or short
previous stop limit
stop limit you are trying to establish

As a sugestion
you might change your code into something :
if (long)
stop < current
SetStopLoss..
else
ExitLong..

if (shot)
stop > current
SetStopLoss
else
ExitShort

(be carefull with exitposition, close to stop's, you might have an OverFill ;-)
which is another headacht

Thank you. The problem I seem to be having is with the syntax of SetStopLoss..., so while your suggestion is good, in terms of cleaning up my code for testing, I'm left with the same syntax that appears to be causing me problems.

Reply With Quote

Reply



futures io > > > > > Intense frustration moving to breakeven+1 in NinjaTrader strategy

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
Plotting the difference between two moving averages in Ninjatrader flight302 NinjaTrader 8 February 17th, 2014 06:24 PM
Multiple moving average crossing strategy parsamkk The Elite Circle 7 August 5th, 2013 10:07 AM
Dax - moving from small loss/breakeven to small profit/profit Disciple Elite Trading Journals 67 April 30th, 2012 07:59 AM
Frustration: NT not running with MBTrading jmjstrider The Elite Circle 2 May 27th, 2011 05:18 PM


All times are GMT -4. The time now is 08:59 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-13 in 0.11 seconds with 19 queries on phoenix via your IP 54.160.245.121