![]() |
|
|||||||
| ATM Strategies (Discretionary Trading) Support for Advanced Trade Management, AutoTrail, AutoBreakeven, Stop Strategy and Simulated Stops etc... |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#16 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
Hi Brett, because this default point value for equities in ninjatrader is wrong I'm having to try and perform a workaround. However the workaround isn't working either and would appreciate some advice. The code below says if it's a stock then multiply the point value by 100. If it's a future leave as point value. The problem is this part doesn't work:
//if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Stock); I'm not sure if I'm using this correctly and would appreciate some guidance. If I put in the actual stock name such as this it works ok. (please see code): if (Instrument.MasterInstrument.Name == "TNA") PHP Code:
Any ideas on this one? Thanks in advance DJ
Last edited by djkiwi; 06-18-2012 at 11:22 AM.
|
|
|
|
|
|
#17 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
|
DJ,
Do you have the semi colon at the end of your statement checking for InstrumentType? Can you remove that and try again? Can you run a quick test using the following segment and let me know if "Is stock" is printed to the output window, or if it does not return: Code:
if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Stock)
{
Print("Is stock");
}
Matthew
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Matthew for this post: |
|
|
|
#18 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
Thanks Matthew for picking that up. Now it works perfectly. It was indeed the issue and need to pay closer attention to these things. I have another odd one though I'd appreciate some help. I'm using this for the unrealized gain calculation:
Variables: private double unrealized = 0; Onbarupdate() unrealized = GetAtmStrategyUnrealizedProfitLoss(atmStrategyId1) ; Then use drawtextfixed in an Infopanel to show the unrealized gain/loss on the chart: "Unreal: " + "$"+((unrealized)).ToString("N0") + "\n"+ Issue: Now I have been using this for sometime with futures without any issue at all. It calls this: if (GetAtmStrategyMarketPosition(atmStrategyId1) != MarketPosition.Flat) So once in a position it will invoke the real time unrealized part above. For some unknown reason there is a problem with equities which appears in the log. I've attached a picture of it. This is a method error. Is there some different type of method for equities than futures? Never had a single error with futures. Thanks DJ Thanks in advance DJ |
|
|
|
|
|
#19 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
|
Hello,
Are you also checking the atmStrategID contains a value? Please refer to our Reference Sample on SampleATMPnL: Code:
if (atmStrategyId.Length > 0)
{
unrealizedProfitLoss = Instrument.MasterInstrument.Round2TickSize(GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
}
Matthew
NinjaTrader Customer Service |
|
|
|
|
|
#20 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
Hi Matthew, unfortunately that doesn't work either. I ran the sample atmPNL strategy on an equities instrument and put a sell stop order on my charts (see chart). I set COBC to false. Once the order was triggered I got the same error (see attached). There seems to be some problem using this unrealized code on equities. I also put this in my code:
PHP Code:
Cheers DJ |
|
|
|
|
|
#21 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
|
DJ,
I have no issues running this on Stocks, Futures or Forex and never receive this area. Are you resetting atmStrategyId1 anywhere in your code? Can you download and run the SampleATMPnL strategy on a stock with or without errors?
Matthew
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Matthew for this post: |
|
|
|
#22 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
Hi Matthew, this is very strange. All I did was run the sampleatmpnl with nothing else and same errors. I tried it again. Same thing. Here are the charts and sampleatmpnl with my atm strategy included.
I'm not resetting anything here just running sampleatmpnl. Cheers DJ
Last edited by djkiwi; 06-19-2012 at 01:25 PM.
|
|
|
|
|
|
#23 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
|
Hello,
I only received errors with your version of the script when I did not have an ATM Strategy called TNAtwotargets Once I named an ATM Strategy TNAtwotargets, everything worked as expected. Can you double check your ATM Strategy name and the string you're using?
Matthew
NinjaTrader Customer Service |
|
|
|
|
|
#24 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
Hi Matthew, the name is correct. I've also tried different names. If you look at the screenshot in my last message you can see the chart on the left shows sampleATMpln running and the the chart on the right is showing the trade AFTER the sampleATMpnl strategy has placed the order. If the name was incorrect no orders would have been placed. The moment the strategy places the order then I get the message. No other strategies are loaded apart from sampleATMpnl
Here is a screenshot of the strategy name. Everything works fine apart from this unrealized issue. As I said before no problems on futures. It's got me baffled. Cheers DJ |
|
|
|
|
|
#25 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
|
DJ,
Interesting. Would you be able to email me the script with issues to support[at]ninjatrader[dot]com. Please also include a reference to this thread.
Matthew
NinjaTrader Customer Service |
|
|
|
|
|
#26 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
Hi Matthew, all of my scripts have the same issue. I'm guessing that because sampleATMPnl has the same issue means there is some other default setting for equities somewhere on ninjatrader that is a problem. Bear in mind this is an equities only issue not futures. I have never seen this issue once trading futures. I want to bring my equities trading to Ninjatrader now.
Cheers DJ |
|
|
|
|
|
#27 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,770
Thanks: 158
Thanked 562 times in 553 posts
|
DJ,
Can you please send me your database file so I can look into this further. You can do this by going to the Control Center-> Help-> Mail to Support-> check "Database file" Please reference this thread in the body of the email
Matthew
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |