Trading Articles
Article Categories
Article Tools
Need help on NinjaTrader 8 Strategy issue with HalfTrend indicator
Updated May 24, 2023
Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
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
(If you already have an account, login at the top of the page)
Need help on NinjaTrader 8 Strategy issue with HalfTrend indicator
(login for full post details)
#1 (permalink )
Mississauga, Canada
Experience: None
Platform: NinjaTrader
Trading: Futures
Posts: 7 since Apr 2023
Thanks: 0 given,
2
received
Hello,
i am creating a strategy for NinjaTrader 8 that receives a signal from HalfTrind indicator to buy or sell
when i receive a signal, i check if there is any other position is open, then i close it and open the new one.
currently, when i try to open a new order, i got this error message:
Buy stop or buy stop limit orders can't be placed below the market. affected order: BuyToCover 1 stopMarket @1234 .00
another message:
Strategy submitted an order that generated the following error 'Order rejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
i debug the code, and this was the value when i get the erro
Short High[0]: 4138.25 currentATR: 3.0280371924987 newStop: 4141.2780371925 _stop: 4141.2780371925
Code
if (Position.MarketPosition == MarketPosition.Flat)
{
EnterShort("ShortOrder");
var newStop = High[0] + currentATR;
_shortStop = _shortStop == 0 ? newStop : _shortStop;
_shortStop = Math.Min(_shortStop, newStop);
Print("3 " + ShortOrder + " High[0]: " + High[0] + " currentATR: " + currentATR + " newStop: " + newStop + " _stop: " + _shortStop);
ExitShortStopMarket(_shortStop, "Trail Short", ShortOrder);
//SetStopLoss(CalculationMode.Price, _shortStop);
}
else if (Position.MarketPosition == MarketPosition.Long)
{
ExitLong("LongOrder");
if (Low[0] < Position.AveragePrice)
{
EnterShort("ShortOrder");
var newStop = High[0] + currentATR;
_shortStop = _shortStop == 0 ? newStop : _shortStop;
_shortStop = Math.Min(_shortStop, newStop);
Print("4 " + ShortOrder + " High[0]: " + High[0] + " currentATR: " + currentATR + " newStop: " + newStop + " _stop: " + _shortStop);
ExitShortStopMarket(_shortStop, "Trail Short", ShortOrder);
//SetStopLoss(CalculationMode.Price, _shortStop);
}
}
Can you help answer these questions from other members on futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
bologna italy
Experience: Advanced
Platform: nt8
Broker: NinaTrader
Trading: futures
Posts: 39 since Jun 2022
Thanks: 10 given,
34
received
mohelsheikh
Hello,
My problem is, I'm getting an error message when I try to make a long request, a short request
The strategy sent cancellation requests and attempted to close the position and terminate itself.
Sell Stop or Sell
Stop orders cannot be placed above the market. Affected order: Sell 1 StopMarket @ 4133.5
It could help if you may post your strategy or, at least, the order placing section
(login for full post details)
#3 (permalink )
London, Canada
Posts: 7 since Apr 2023
Thanks: 3 given,
1
received
I am getting the exact same errors as you with a different strategy than yours. It executes the buy, target and stop perfectly when the market (es, nq) is moving slowly(eth ) but during regular trading hours, when the market moves quickly, I get the same error "Sell stop or sell stop orders cannot be placed above the market"(or Below the Market) This disables my strategy and leaves my live order hanging in the market without a stop or takeprofit. This could be because the market moved quickly past the stop and won't execute at that level anymore. I'm wondering if there's any error proofing someone could post that would ensure that the stop or target executes at whatever price the market is currently at, even if its a few ticks past my stop or target. I'm using rithmic data feed with NT8 version 8.1.1.6
Cheers, Derek.
mohelsheikh
Hello,
I am creating a
NinjaTrader 8 strategy, and this strategy reads the HalfTrend indicator to determine entry
points . When the strategy receives an UpSignal[0] from indicatoe, it will automaticly place a
market order . If it is short, it will exit any current long position first and then enter a long position. I keep long open until I receive SnSignal[0], check MarketPosition, if fLong, exit long then enter sell, and so on.
My problem is, I'm getting an error message when I try to make a long request, a short request
The strategy sent cancellation requests and attempted to close the position and terminate itself.
Sell Stop or Sell Stop orders cannot be placed above the market. Affected order: Sell 1 StopMarket @ 4133.5
(login for full post details)
#4 (permalink )
Mississauga, Canada
Experience: None
Platform: NinjaTrader
Trading: Futures
Posts: 7 since Apr 2023
Thanks: 0 given,
2
received
BERN Algos
It could help if you may post your strategy or, at least, the order placing section
Thank you,
I did, it is in the post
(login for full post details)
#6 (permalink )
London, Canada
Posts: 7 since Apr 2023
Thanks: 3 given,
1
received
Thank you very much for your reply. It looks like getting the current ask/bid should work in my situation. I'll try it as soon as the market opens and let you know how I make out. Enjoy your weekend! Derek.
trendisyourfriend
(login for full post details)
#7 (permalink )
London, Canada
Posts: 7 since Apr 2023
Thanks: 3 given,
1
received
So, in the code below, in OnBarUpdate(), the support price I'm using is based on the indicator sr. How would I use GetCurrentAsk() ?
var support = _sr.SupportPrice[0];
if (Low[0] <= support && Close[0] >= support)
{
if (_lastLevel.ApproxCompare(support) != 0)
{
_lastBar = CurrentBar;
_lastLevel = support;
SetProfitTarget(CalculationMode.Ticks, TakeProfit);
var ticks = (Close[0] - Low[0]) / TickSize;
if (ticks < 4) ticks = 4;
ticks += ExtraSLTicks;
SetStopLoss(CalculationMode.Ticks, ticks);
EnterLong(1, 1, "buy");
return;
}
}
trendisyourfriend
(login for full post details)
#8 (permalink )
Legendary Market Wizard
Quebec Canada
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Posts: 4,367 since Oct 2009
Thanks: 4,050 given,
5,769
received
Quoting
Entry() methods will
reverse the position automatically. For example if you are in a 1
contract long position and now call EnterShort() -> you will see 2 executions, one to close the prior long position and the other to get you into the desired 1 contract short position.
Take the time to read the Help section and ask your questions on the Ninjatrader forum. There seems to be a minority of people using Ninjatrader on Futures.io these days.
https://ninjatrader.com/support/helpGuides/nt8/managed_approach.htm
(login for full post details)
#9 (permalink )
Mississauga, Canada
Experience: None
Platform: NinjaTrader
Trading: Futures
Posts: 7 since Apr 2023
Thanks: 0 given,
2
received
trendisyourfriend
thank you so much for your help
amazing
Mohamed
The following user says Thank You to mohelsheikh for this post:
Last Updated on May 24, 2023