NexusFi: Find Your Edge


Home Menu

 





Adding 2nd target


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Ryanb with 4 posts (0 thanks)
    2. looks_two Trader.Jon with 2 posts (2 thanks)
    3. looks_3 gulabv with 1 posts (1 thanks)
    4. looks_4 zeller4 with 1 posts (1 thanks)
    1. trending_up 3,730 views
    2. thumb_up 4 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
Ryanb's Avatar
 Ryanb 
Netherlands
 
Experience: Advanced
Platform: none
Trading: Stocks
Posts: 195 since Sep 2010
Thanks Given: 117
Thanks Received: 358

Hi there,

i have made a strategy in the strategy wizard and i wanted to add an 2nd contract with a higher target, but when i add the target it wont work, aldough the code seems to be right (i can adjust the settings when starting up the strategy, and no errors occur.)

What i did was simply copying the current target and stop and made it target 2 and stop 2. can someone tell me what i need to do more?

I've watched big mikes advanced strategy coding video but if i do his part of coding for the stops NT is giving errors all over the place.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Topstep Acquires The Futures Desk -- Prop Firm Consolida …
Funded Trading Evaluation Firms
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
February NFP Preview -- Why This Mornings Jobs Number Co …
Traders Hideout
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
  #3 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 478 since Jun 2009
Thanks Given: 1,419
Thanks Received: 404


Ryan,

You need to tell us if you're on 6.5 or 7 and the "type" of entry syntax you're using... There are different methods.

ie EnterLong()...

kz


Reply With Quote
Thanked by:
  #4 (permalink)
 
Ryanb's Avatar
 Ryanb 
Netherlands
 
Experience: Advanced
Platform: none
Trading: Stocks
Posts: 195 since Sep 2010
Thanks Given: 117
Thanks Received: 358

Hi there,

i use this entry:

EnterLong(DefaultQuantity,
"");

and i`m coding in NT 7

This is my current stop and profit code, it does work but uses only the first target.


Quoting 

[Description(
"")]
[GridCategory(
"Parameters")]
publicint Target1
{
get { return Profit1; }
set { Profit1 = Math.Max(1, value); }
}
[Description(
"")]
[GridCategory(
"Parameters")]
publicint Target2
{
get { return Profit2; }
set { Profit2 = Math.Max(1, value); }
}

[Description(
"")]
[GridCategory(
"Parameters")]
publicint Stop1
{
get { return stop1; }
set { stop1 = Math.Max(1, value); }
}

[Description(
"")]
[GridCategory(
"Parameters")]
publicint Stop2
{
get { return stop2; }
set { stop2 = Math.Max(1, value); }


Started this thread Reply With Quote
  #5 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

Please supply screen shots of the code working (print statements for entrys please), both versions with and without the second target, and is there any errors in the compile or the control centre log???

TJ


Reply With Quote
Thanked by:
  #6 (permalink)
 
Ryanb's Avatar
 Ryanb 
Netherlands
 
Experience: Advanced
Platform: none
Trading: Stocks
Posts: 195 since Sep 2010
Thanks Given: 117
Thanks Received: 358

Thank you guy`s for the support!

when i start the strategy this stands in the outputwindow:

Quoting 
**NT** Enabling NinjaScript strategy 'Slingshot/0070cb6b45cc4b76ba388ab3d83877ae' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=True EntryHandling=UniqueEntries EntriesPerDirection=2 StopTargetHandling=ByStrategyPosition ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes

in the ninjascript editor it has absolutely no errors at all.

Screenshot added of the strategy that has 2 entry`s and 2 stops.
the other system with 1 stop is exactly the same but then without the 2 entry`s


Attached Thumbnails
Click image for larger version

Name:	screenshot.JPG
Views:	219
Size:	119.8 KB
ID:	22895  
Started this thread Reply With Quote
  #7 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

I will have to watch for comment, but I 'think' you can only use 1 value for StopLoss in NT (without using custom code) ... you can check this out if you swap around the values for Stop1 and Stop2 and see which gets used. ...

TJ


Reply With Quote
Thanked by:
  #8 (permalink)
 
gulabv's Avatar
 gulabv 
Dallas, TX
 
Experience: Beginner
Platform: Ninjatrader
Broker: Zen-Fire
Trading: ZN, 6E
Posts: 286 since May 2010
Thanks Given: 161
Thanks Received: 169

ryanb,

Are you trying to setup 2 orders with different profit targets and stop loss? If so you need to give each entry order a name within the double quotes when you call EnterLong and then associate that order name with the respective exit order calls to use target1 and stop1, target2 and stop2. This will associate your different PT and SL with each order.

hope that helps,
gulabv


Reply With Quote
Thanked by:
  #9 (permalink)
 
Ryanb's Avatar
 Ryanb 
Netherlands
 
Experience: Advanced
Platform: none
Trading: Stocks
Posts: 195 since Sep 2010
Thanks Given: 117
Thanks Received: 358

thanks gulabv,

i wanted to create one entry and 2 targets, but i just made 2 entry`s on 1 signal with 2 diffirent names and that did the trick!

now i`m going to set a break even on it as well


Started this thread Reply With Quote




Last Updated on October 15, 2010


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts