NexusFi: Find Your Edge


Home Menu

 





Set Profit and Loss Variables


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one brightredmegaphone with 11 posts (1 thanks)
    2. looks_two Xeno with 8 posts (2 thanks)
    3. looks_3 baruchs with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 9,638 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 20 posts
    2. attach_file 5 attachments




 
Search this Thread

Set Profit and Loss Variables

  #1 (permalink)
 brightredmegaphone 
Brisbane, Australia
 
Experience: Advanced
Platform: Ninja, MT4
Trading: FX
Posts: 30 since Sep 2010
Thanks Given: 2
Thanks Received: 13

hi
I currently run a simple automated strategy using MT4, and I want to try & replicate it in NT4, so that I can backtest and refine some of the variables. I'm having difficulty replicating the profit target in the condition builder (i'm don't have a developers mind Im afraid)

In a long position:
if the current bar is the trigger bar, I want to buy on the next bar if it breaks x pips above the trigger bar (complete)
I then want to establish a stop loss that initially is set below the trigger bar by x pips
I also want to establish a profit target based on the range of the trigger bar - say initially 100%
Stage 2 is then to split the order & take the first lot off after 100% of trigger bar is reached & x% after that

So far I have created the low & high of the trigger bar as user variables, but not sure how to apply these to the setstoploss and setprofittarget in the condition builder. If I can achieve this, I could then move onto Stage 2.

Any help at this stage gratefully received - even if someone says "go get a programmer to develop it"

Michael

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Quant vue
Trading Reviews and Vendors
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
 
  #3 (permalink)
 Xeno 
UK
 
Experience: Intermediate
Platform: Ninja
Broker: Mirus/Zen
Trading: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks Given: 70
Thanks Received: 274


I've never used the strat wizard, but I had a quick look at it. When you're on the window defining stops/targets, in the parameters box, next to 'values', on the right hand side there's a small box with some dots in it. Click that - it gives you access to user variables.

Reply With Quote
Thanked by:
  #4 (permalink)
 brightredmegaphone 
Brisbane, Australia
 
Experience: Advanced
Platform: Ninja, MT4
Trading: FX
Posts: 30 since Sep 2010
Thanks Given: 2
Thanks Received: 13


Xeno View Post
I've never used the strat wizard, but I had a quick look at it. When you're on the window defining stops/targets, in the parameters box, next to 'values', on the right hand side there's a small box with some dots in it. Click that - it gives you access to user variables.

Thx Xeno: in the end I watched Mike's video & have started to attempt to modify that. The main difference is that i wanted to set targets based on %'s rather than just ticks, & then have entered on a stop order (next bar) rather than market order. I gave up on the % entry idea for now, as it seems a bit beyond me, but the rest seems okay, with a couple of exceptions:

Shorts: b/e doesn't move up after 1st lot, but does move up after 2nd
Longs: b/e does move up after 1st, but the 3rd lot doesn't move

I think, if they are doing different things, I have been staring at the screen a little too long. Not sure if anyone can have a quick look, I suspect it is something very obvious.

Thank you.

Attached Files
Elite Membership required to download: ThreeProfitStops.zip
Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 Xeno 
UK
 
Experience: Intermediate
Platform: Ninja
Broker: Mirus/Zen
Trading: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks Given: 70
Thanks Received: 274

I think doing a quick c# (and Ninja Script) tutorial would help. You have all sorts of stuff that is not quite right. Some that occur to me at first glance:

- you probably don't need to be declaring things like smav1 everywhere you assign them
- your three SetStopLoss lines do the same thing - they have the same parameters, just a different label (set TraceOrders = true in Initialize()) (same applies to enter short and long stop lines)
- in ManageOrders() your breakeven3 lines are executed regardless of position (long or short) because you've terminated the if with '}' after breakeven2. Your breakeven3 lines are surrounded by meaningless {} You need to look up how 'if' works.

Reply With Quote
Thanked by:
  #6 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
Posts: 323 since Jun 2009


brightredmegaphone View Post
Shorts: b/e doesn't move up after 1st lot, but does move up after 2nd
Longs: b/e does move up after 1st, but the 3rd lot doesn't move

Thank you.

Its wrong to code scaling into a strategy.

Wrong. Wrong. Wrong!!!!!!!!!!!

Baruch

Reply With Quote
  #7 (permalink)
 brightredmegaphone 
Brisbane, Australia
 
Experience: Advanced
Platform: Ninja, MT4
Trading: FX
Posts: 30 since Sep 2010
Thanks Given: 2
Thanks Received: 13

I basically wanted to test a simple 3 profit/stop system using an on-stop order system that buys above market. The stops would move to b/e once the 1st lot had been achieved. I wanted this in 2 ways: - one based on fixed ticks (say, 20, 40, 60) & one based on percentages. Say 100, 200, 500% of previous bar ranges.

I have used this system manually on day trading swing charts for ages; I would have thought it was fairly easy to setup or that it had already been setup somewhere. It was the entire reason for me looking into NT, as if it could be setup in the condition builder I had enough nous (hopefully) to establish my own patterns, price action rules etc. I use very few indicators in my trading.

I have had various replies that I should set it up myself (don't have coding background with enough experience) or that it is too difficult to set up in condition builder, but I had thought it would have been developed somewhere. Maybe if I join Elite I might find it there?

Thanks for help.

Michael
BTW, not sure what last post was, something bout scaling & being wrong is this a reference to my trading or my coding?

Started this thread Reply With Quote
  #8 (permalink)
 Xeno 
UK
 
Experience: Intermediate
Platform: Ninja
Broker: Mirus/Zen
Trading: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks Given: 70
Thanks Received: 274

Hi Michael,

I think it's unlikely it exists in the elite section, but you should probably still join up ;-)

The reason it probably doesn't exist is that it's a very simple strategy, that probably won't make money. You say you've used it manually for ages. Does it make money consistently? Can you honestly say that you've followed the rules you intend to code 100% accurately, with no discretion? Are the levels going to be fixed, or are you changing them every day based on some clever analytics (which could then make your system profitable)

Sorry to be rather negative, but people who have coded and tested lots of systems would probably tell you a similar thing.

(regarding the scaling post - I think he means you shouldn't code a strategy that does scaling - i.e scaling into and out of positions. Personally I don't see why you shouldn't, I'd be interested to know why he thinks that)

Reply With Quote
  #9 (permalink)
 brightredmegaphone 
Brisbane, Australia
 
Experience: Advanced
Platform: Ninja, MT4
Trading: FX
Posts: 30 since Sep 2010
Thanks Given: 2
Thanks Received: 13

hi Xeno

All I'm after is a modified version of what is already here on this site:
.

Instead of fixed size tick, I wanted %'s of previous ranges & I wanted to buy above market onstop, rather than just entry order. It was really just the entry/exit strategy around which I would create my own price action strategies. I've been running a hedge fund around such things for years, just really wanted to see if some of my systems could be automated.

Thanks for your input, I'm sure a man of your calibre could knock it up in 5 mins

Started this thread Reply With Quote
  #10 (permalink)
 brightredmegaphone 
Brisbane, Australia
 
Experience: Advanced
Platform: Ninja, MT4
Trading: FX
Posts: 30 since Sep 2010
Thanks Given: 2
Thanks Received: 13


hey Mike
Wondered if you read this whether you could comment; I've developed a simple strategy using your video as the backbone - 3 simple take profits with a simple feature. I'm not worried about profitability here, I'm worried about the tendency, seemingly randomly, for the code to work & then not.

The stop is supposed to move to b/e once targets are hit, which most of the time it seems to accomplish. There are however certain times when for no apparent reason, it doesn't do as it should. So far, Ninja Support haven't been too helpful so I thought as the title suggests, I would go to the butcher and not the block.

Thanks for any help.

Michael

Attached Files
Elite Membership required to download: GAPbounce3profitlong.zip
Started this thread Reply With Quote




Last Updated on December 10, 2010


© 2024 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 - Privacy Policy - Downloads - Top
no new posts