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 Big Mike with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 9,455 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

  #11 (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

Saying it doesn't do as it should doesn't help much. We need to know exactly what it does and doesn't do.

It'll help greatly if you get into the habit of putting Prints in your code while developing. I suggest you put a load of Prints in, printing out various variables to see their value. You should also put the line

 
Code
TraceOrders = true;
in your Initialize method, then you will see what stops, targets and entries are being generated. Then, after you've looked at the output in the output window, if you can't figure it out, post the output and the code here.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
  #12 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534

Xeno has good advice. I can't really help much, I stopped using Ninja a while back.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #13 (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
Saying it doesn't do as it should doesn't help much. We need to know exactly what it does and doesn't do.

It'll help greatly if you get into the habit of putting Prints in your code while developing. I suggest you put a load of Prints in, printing out various variables to see their value. You should also put the line

 
Code
TraceOrders = true;
in your Initialize method, then you will see what stops, targets and entries are being generated. Then, after you've looked at the output in the output window, if you can't figure it out, post the output and the code here.

Thx for this Xeno. I've attached 2 jpegs from the same chart, same code etc. In 1, the code works fine; 3 longs are executed, , lots 1 & 2 reach targets & the stoploss moves up accordingly and is eventually hit.

In the other eg, same thing - 3 lots entered long (correct) 1st target hit, then it seems only the 2nd lot moves to b/e, the 3rd remains & is hit as an original stop loss. What I am trying to achieve is that 3 lots are entered, once 1st lot hits target, remaining 2 stop losses move up to b/e. Then, as 2nd target is achieved, the 3rd lot remains @ b/e still & does not move.

I am quite close & have set trace=true as you suggested. I am missing something obvious I think.

Thx for your responses so far.

Michael

Attached Thumbnails
Click image for larger version

Name:	GAPbounce 1.jpg
Views:	204
Size:	48.1 KB
ID:	26786   Click image for larger version

Name:	GAPbounce 2.jpg
Views:	194
Size:	43.1 KB
ID:	26787  
Started this thread Reply With Quote
  #14 (permalink)
 brightredmegaphone 
Brisbane, Australia
 
Experience: Advanced
Platform: Ninja, MT4
Trading: FX
Posts: 30 since Sep 2010
Thanks Given: 2
Thanks Received: 13

Sorry this is the new script, I did do a bit of work on it today; nearly there.

Attached Files
Elite Membership required to download: GAPbounce3profitlong.zip
Started this thread Reply With Quote
  #15 (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

What's happened to your {} around your if blocks in ManageOrders? Where are the prints and output I suggested?

Reply With Quote
  #16 (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
What's happened to your {} around your if blocks in ManageOrders? Where are the prints and output I suggested?

I re-read your post & took the quotes out of ManageOrders, that's what you said and it seemed to help.'Obviously I missed something.

Wasn't sure where to put Print/Outputs or even to look for them. Sorry if I'm a bit slow but coding is a bit new to me. Bit of cut 'n paste really.

See you're from London, you'd be enjoying the Ashes then.

Started this thread Reply With Quote
  #17 (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

Yes, I'm loving the Ashes. Thanks.

You need to do that c# tutorial I mentioned. For example, C# Station: C# Tutorial Lesson 03 - Control Statements - Selection

Seriously, the time you put in to work out how to use 'if' and {} and other basic constructs will be invaluable. You can't really program without that knowledge. You can come on here and keep asking, but ultimately it'll get frustrating.

Print statements are simple.

Try, for example, lots of lines like this -

 
Code
Print(Time[0]+" Moving stop target 2 to b/e");
Then bring up an output window (Alt-O) and run. Once you see how powerful Print is for debugging your code you'll never look back.

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

Thx, Xeno I'll have a look. I'm not sure how much programming I really want to do we shall see. I currently run a fund that uses MT4 servers; I just jumped into NT to have a look as I thought I could test some of my own ideas. The jury is still out for the moment. I tend to focus more on the ideas rather than the complete implementation.

In the meantime, if you feel so inclined can you see any obvious errors that might clear up this problem; scaling out of orders is a fairly standard method & I think it is nearly correct. Appreciate the assistance it has taken a while to get there.

BTW, don't expect Australia to improve much in this series, I don't think anyone is expecting them too here.

Michael

Started this thread Reply With Quote
  #19 (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

Well, I already told you that not having {} after your ifs is probably not want you want. I don't see anything else obvious, but us programmers tend to use prints. Computers are so much better at running code than your head.

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


Thx Xeno, finally got it to work.

I did enter in some print outputs, where do I find those?

Appreciate the patience.

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