Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Call ATM Strategy on an automated strategy to control position
Updated May 31, 2016
Top Posters
looks_one
mrticks
with 3 posts (2 thanks)
looks_two
harcesis
with 2 posts (0 thanks)
looks_3
redratsal
with 1 posts (3 thanks)
looks_4
zeller4
with 1 posts (0 thanks)
trending_up
6,537 views
thumb_up
5 thanks given
group
5 followers
forum
7 posts
attach_file
0 attachments
Call ATM Strategy on an automated strategy to control position
November 15th, 2009, 10:15 AM
POrtugal
Posts: 52 since Nov 2009
Hello,
How can I call an ATM Strategy on an automated ninjascript strategy to control my position?
I have a strategy (VervoortMACrossover) that is working realy good but I want to control my position so I can go breakeven + trailstop.
I have no idea how to doo that.
Can some one help me?
Best regards,
JJ
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
November 16th, 2009, 01:14 PM
Orlando Florida
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404
try the built-in SampleAtmStrategy
March 11th, 2011, 04:41 AM
Dublin, Ireland.
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
jsengxx
Hello,
How can I call an
ATM Strategy on an automated ninjascript strategy to control my position?
I have a strategy (VervoortMACrossover) that is working realy good but I want to control my position so I can go
breakeven + trailstop.
I have no idea how to doo that.
Can some one help me?
Best regards,
JJ
I submitted a template for this on the NT forums a while back. The link for the page is Links and Downloads Manager - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum and it's the one called "SampleATMCancelStrategy" near the bottom of the page.
Hope it helps!
March 11th, 2011, 11:16 AM
Milan (I)
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090
jsengxx
Hello,
How can I call an
ATM Strategy on an automated ninjascript strategy to control my position?
I have a strategy (VervoortMACrossover) that is working realy good but I want to control my position so I can go
breakeven + trailstop.
I have no idea how to doo that.
Can some one help me?
Best regards,
JJ
Try this
In Variables
private int trailstop = 10 ;
protected override void OnBarUpdate()
if (Position.MarketPosition == MarketPosition.Long)
{
// Once the price is greater than entry price+ ticks, set stop loss to breakeven
if (Close[ 0 ] > Position.AvgPrice - trailstop * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice - trailstop * TickSize);
}
}
In region properties
[Description( "" )]
[GridCategory( "Parameters" )]
public int TrailStop
{
get { return trailstop; }
set { trailstop = Math.Max( 1 , value); }
}
adjust your trailstop accordingly for breakeven set it to 0
May 16th, 2016, 02:24 PM
Prague/Czech Republic
Experience: Intermediate
Platform: Ninjatrader
Trading: YM, RTY
Posts: 13 since Sep 2011
Thanks Given: 2
Thanks Received: 0
mrticks
Hello Mrticks,
I found your sample template on ninjatrader support forum and I would like to use it since I am not able to program some decent trailing stop loss strategy via strategy wizard.
I have three questions:
1. can I change name of the ATM templates - where in your code I need to change it?
2. how I can merge my conditions with your strategy - should I just copy and paste into on bar update session?
3. is it backtesteble. I read in ninja help that ATM strategy is not backtesteble?
Thank you very much for your feedback in advance.
Miroslav
May 19th, 2016, 11:37 AM
Dublin, Ireland.
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
harcesis
Hello Mrticks,
I found your sample template on
ninjatrader support forum and I would like to use it since I am not able to program some decent trailing stop loss strategy via strategy wizard.
I have three questions:
1. can I change name of the
ATM templates - where in your code I need to change it?
2. how I can merge my conditions with your strategy - should I just copy and paste into on bar update session?
3. is it backtesteble. I read in ninja help that ATM strategy is not backtesteble?
Thank you very much for your feedback in advance.
Miroslav
Hello Miroslav,
I have not used NT in over 5 years but I will try to help!
1. Look for this section in the code, this is where you need to edit your ATM template names to match what you have created locally.
Code
// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'TF_long_3W_3BR' and 'TF_short_3W_3BR' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK you can create your own****
if (orderIdL.Length == 0
&& atmStrategyIdL.Length == 0
&& FirstTickOfBar
&& Close [1] <= Open [1]
&& High [1] + PrevBarsPlusTicks * TickSize > GetCurrentBid())
{
atmStrategyIdL = GetAtmStrategyUniqueId();
orderIdL = GetAtmStrategyUniqueId();
orderBarL = CurrentBar;
AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, 0, High[1] + PrevBarsPlusTicks * TickSize, TimeInForce.Day, orderIdL, "TF_long_3W_3BR", atmStrategyIdL);
}
if (orderIdS.Length == 0
&& atmStrategyIdS.Length == 0
&& FirstTickOfBar
&& Close [1] >= Open [1]
&& Low [1] - PrevBarsMinusTicks * TickSize < GetCurrentAsk())
{
atmStrategyIdS = GetAtmStrategyUniqueId();
orderIdS = GetAtmStrategyUniqueId();
orderBarS = CurrentBar;
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Stop, 0, Low[1] - prevBarsMinusTicks * TickSize, TimeInForce.Day, orderIdS, "TF_short_3W_3BR", atmStrategyIdS);
2. Yes, look for this section and insert your code in their:
Code
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
3. I could never get NT to backtest with an ATM being called via a strategy!
Have fun!
May 26th, 2016, 03:24 PM
Prague/Czech Republic
Experience: Intermediate
Platform: Ninjatrader
Trading: YM, RTY
Posts: 13 since Sep 2011
Thanks Given: 2
Thanks Received: 0
mrticks
Hello Miroslav,
I have not used NT in over 5 years but I will try to help!
1. Look for this section in the code, this is where you need to edit your
ATM template names to match what you have created locally.
Code
// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'TF_long_3W_3BR' and 'TF_short_3W_3BR' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK you can create your own****
if (orderIdL.Length == 0
&& atmStrategyIdL.Length == 0
&& FirstTickOfBar
&& Close [1] <= Open [1]
&& High [1] + PrevBarsPlusTicks * TickSize > GetCurrentBid())
{
atmStrategyIdL = GetAtmStrategyUniqueId();
orderIdL = GetAtmStrategyUniqueId();
orderBarL = CurrentBar;
AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, 0, High[1] + PrevBarsPlusTicks * TickSize, TimeInForce.Day, orderIdL, "TF_long_3W_3BR", atmStrategyIdL);
}
if (orderIdS.Length == 0
&& atmStrategyIdS.Length == 0
&& FirstTickOfBar
&& Close [1] >= Open [1]
&& Low [1] - PrevBarsMinusTicks * TickSize < GetCurrentAsk())
{
atmStrategyIdS = GetAtmStrategyUniqueId();
orderIdS = GetAtmStrategyUniqueId();
orderBarS = CurrentBar;
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Stop, 0, Low[1] - prevBarsMinusTicks * TickSize, TimeInForce.Day, orderIdS, "TF_short_3W_3BR", atmStrategyIdS);
2. Yes, look for this section and insert your code in their:
Code
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
3. I could never get NT to
backtest with an ATM being called via a strategy!
Have fun!
Hello Mrticks,
thank you for your replay. Sorry for delay I am trying to fix overfill issues until I will proceed with adding ATM strategy.
I am using unirenko charts and it seems it is opening extra positions in high volatility times.
I am trying to use bool logic to prevent extra entry if trade was once triggered.
Can I come back to you when I fix my overfill issue?
Thank you
Miroslav
May 31st, 2016, 04:51 PM
Dublin, Ireland.
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
harcesis
Hello Mrticks,
thank you for your replay. Sorry for delay I am trying to fix overfill issues until I will proceed with adding
ATM strategy.
I am using unirenko charts and it seems it is opening extra positions in high
volatility times.
I am trying to use bool logic to prevent extra entry if trade was once triggered.
Can I come back to you when I fix my overfill issue?
Thank you
Miroslav
Best of luck with the overfill issue!
Last Updated on May 31, 2016