NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > ATM Strategies (Discretionary Trading)

ATM Strategies (Discretionary Trading) Support for Advanced Trade Management, AutoTrail, AutoBreakeven, Stop Strategy and Simulated Stops etc...

Reply
 
Thread Tools Display Modes
Old 06-15-2012, 10:22 AM   #1
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default Setting ATM Quantities

Hi Guys. I have an ATM strategy question. I'm using this code to create an ATM strategy buy order:

PHP Code:
if (DrawObjects["T3"]==null){AtmStrategyCreate(Cbi.OrderAction.BuyOrderType.Limit,  GetCurrentBid(), 0,TimeInForce.GtcorderId1atmnameatmStrategyId1);} 
So today I started trying to apply a futures ATM strategy to a stock ATM strategy and got into some problems. The picture shows calling the strategy to buy 100 apple shares with two targets. The problem as you can see on the chart is once the limit order is set it is set to buy 51 shares instead of 100. Then once it fills it has 1st target of 50 and second target with the 1. I'm sure it is something simple.

Any ideas on this one?

Thanks in advance
DJ
Attached Images
File Type: png ATM Issuye.PNG (93.4 KB, 10 views)
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 10:35 AM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for the note.

Appears you got a part fill, as you were only filled with 51 contracts. You were not actually 100 contracts long therefor, you didn't have the full 50 target 1 and 50 target 2 QTY's.

NinjaTrader will submit and modify the stops as you get filled so that you never have a position unprotected, even if you get part filled.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett for this post:
Old 06-15-2012, 11:49 AM   #3
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Thanks Brett, I don't think a partial fill was the issue because I was getting 51 all the time. I realized I'd done something else which had caused some problem with the original ATM strategy so fixed now. I have a another issue though. I'm trying to calculate a reward $ figure based on the type of instrument being a future or a stock.

For futures I use this formula which works well:

PHP Code:
double Reward2TMath.Round(((reward1+reward2) * Instrument.MasterInstrument.PointValue), 2MidpointRounding.AwayFromZero); 
The problem is what do I do for stocks? For example if I buy 100 shares of apple and the target is $1 above the current price then the reward should show $200 but is showing me $2. So I think I need to replace the PointValue part for futures with something else for stocks but could not see any other option...

Thanks
DJ
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 12:07 PM   #4
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

The point value is fine as point value is just 1 for stocks.

Most likely is the rounding in that case.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett for this post:
Old 06-15-2012, 12:10 PM   #5
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Hi Brett, here is another separate question as well. I've attached the AMT strategy. What I want to do is use the same template for multiple instruments but change the quantity for different instruments. For example I've put this in the initialize section.

PHP Code:
if (Instrument.MasterInstrument.Name == "AAPL")
            {    
            
DefaultQuantity 300;
            }    
            
            if (
Instrument.MasterInstrument.Name == "CLF")
            {    
            
DefaultQuantity 200;
            } 
What this should do is then buy 300 shares of APPL or 200 shares of CLF whichever is being purchased. There are two issues:

1. The first problem is if I run this and buy AAPL it isn't buying 300 but only 100 as per the strategy.
2. The second issue is even if it had purchased 300 AAPL shares how do I tell it the targets should be split into two so would be 150 for each target?

Thanks in advance
DJ
Attached Images
File Type: png atm strat1.PNG (103.8 KB, 5 views)
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 12:17 PM   #6
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

1) I would set this in OnStartUp(). As in Initialize() it can be overridden by the user.

2) This is determined by the strategy, you would need an ATM strategy setup for each stock and each QTY level unfortunately..

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett for this post:
Old 06-15-2012, 12:24 PM   #7
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

The point value is fine as point value is just 1 for stocks.

Most likely is the rounding in that case.

-Brett
Thanks Brett, I see that is the problem. So how do I tell it to multiply it by the number of shares purchased? Otherwise all it is doing is saying take the target price of $570 less current price $569 = $1 x 1 for the point value =$1. To get the reward I need to tell it to multiply by the shares purchased. If it is 200 shares then the reward should be $200.

Thanks
DJ
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 12:40 PM   #8
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

http://www.ninjatrader.com/support/h...rderstatus.htm

This should do the trick.
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett for this post:
Old 06-15-2012, 12:55 PM   #9
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Hi Brett, thanks this will help me once I'm in the trade. Let me explain further. Here is a chart of oil. I have programmed it so as I move the stop and target lines up and down it will calculate the risk/reward before entering the trade so I can see my risk and return prior to entry (see top left table). I need to do this for stocks as well so not sure why it doesn't work the same. It is something to do with this point value part as that's were it is all turning to custard.

I think what I need to do is access is the Qty for target 1 and Qty for target 2 in the ATM Strategy parameters section. I don't why this is working differently from the way futures are doing it.

Cheers
DJ
Attached Images
File Type: png atm strat1.PNG (103.8 KB, 6 views)
File Type: jpg CL 07-12 (1000 Volume) 6_15_2012.jpg (194.1 KB, 4 views)
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 01:08 PM   #10
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

To clarify, you need to computer while the previous trade is going? Wouldn't you only be computing this before entry or will you be doing this after entry?

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-15-2012, 01:33 PM   #11
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Hi Brett, sorry for the confusion. There is no trade going and it's only before entry. So as I move the lines around the Reward is constantly updating in the table

Once in the trade it's fixed based on the before entry calculation.

I just tried out this here and notice it only works once you are in the position and not prior to entering the position.

PHP Code:
{DrawTextFixed("markettype22""Q: "+GetAtmStrategyPositionQuantity(atmStrategyId1).ToString("N0"), brPositionColor.BlacktextFontHugeColor.WhiteColor.Lime10);} 
The issue I guess is what makes this line so special in that it works on futures and not on stocks?

double Reward2T= Math.Round(((reward1+reward2) * Instrument.MasterInstrument.PointValue), 2, MidpointRounding.AwayFromZero);


Cheers
DJ
Last edited by djkiwi; 06-15-2012 at 01:40 PM.
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 01:49 PM   #12
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks. Correct will only work after you are in the trade.

Lastly the difference here is still the rounding. Ir probably works on XXXX.XX instruments like the ES but not XX.XX instruments might be the missing factor.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-15-2012, 01:56 PM   #13
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Hi Brett, now I feel like a fool. Because it's a stock it's in denominations of $1 so the Point Value is incorrect for stocks. So what I need to do is multiply it by 100. So I think you guys need to say if it is a stock set the point value to 100 not 1.

I have a chart where you can see it working correctly.

Here is the code:

PHP Code:
double Reward2TMath.Round((((reward1+reward2) * Instrument.MasterInstrument.PointValue)*100), 2MidpointRounding.AwayFromZero); 
Cheers
DJ
Attached Images
File Type: jpg AAPL (10000 Volume) 6_15_2012.jpg (68.1 KB, 9 views)
djkiwi is offline  
Reply With Quote
Old 06-15-2012, 02:01 PM   #14
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

The difference is a point for stocks is 1 cent.

A point for the ES is 4 ticks.

Not really a right or wrong way to do it but we wouldn't change it now.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-15-2012, 02:35 PM   #15
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default

Hi Brett, yes you are right 1 cent. I suggest Ninjatrader consider changing it because it is simply incorrect as it stands. All stocks are 1 cent so the point value should be 100 not 1 for all stocks.

Bear in mind you wouldn't need point value at all if all futures were the same denomination.

In any case thanks for your patience on this issue. Much appreciated.

Cheers
DJ
Last edited by djkiwi; 06-15-2012 at 02:58 PM.
djkiwi is offline  
Reply With Quote
The following user says thank you to djkiwi for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Initial Stop Loss Using ATM Mr_T_Fx Strategy Development 1 08-21-2011 06:30 AM
MOC order if ATM setting not reached? vero-chan ATM Strategies (Discretionary Trading) 1 04-18-2010 01:53 PM
HELp plz. with setting up new ATM......... mdsvtr ATM Strategies (Discretionary Trading) 1 03-11-2010 11:53 AM
Help setting up these ATM Strategys please.... mdsvtr ATM Strategies (Discretionary Trading) 2 03-08-2010 01:07 PM
Re: Setting a trailing stop & ATM Strategy mikesbarrett SuperDOM and other Order Entry Windows 1 06-29-2007 08:57 AM


All times are GMT -6. The time now is 09:09 AM.