NexusFi: Find Your Edge


Home Menu

 





Buy/Sell in an indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Mindset with 6 posts (0 thanks)
    2. looks_two RJay with 2 posts (0 thanks)
    3. looks_3 toulouse-lautrec with 2 posts (1 thanks)
    4. looks_4 gregid with 1 posts (0 thanks)
    1. trending_up 8,330 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Buy/Sell in an indicator

  #11 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

success.

However there is bound to be a much more elegant way to do this - so if anyone does know of a way please let me know.


Essentially you need to throw your entryprice into the following command line
 
Code
entryorder = PLACE;SIM101;"+Instrument.FullName.ToString()+";SELL;
"+positionsize.ToString()+";STOPLIMIT;"+myentryprice.ToString()+";" 
+ myentryprice.ToString()+";DAY;;"+Instrument.FullName.ToString()+
"orderid;;";
and then
 
Code
File.AppendAllText(incomingpath,entryorder);
// nb  incrementing prevents locking which can happen with nos or multiple orders
where incomingpath = Cbi.Core.UserDataDir.ToString() + "\incoming\oif.txt";
This file is made and destroyed instantly and is better if you increment it for each order to prevent locking in cases of multiple orders hitting the file path simultaneously.


Now I am on to monitoring the outgoing file path for an oco order related to the entry!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
 
  #12 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

Ok bit further ahead now - it would help if I had taken a course in C# or even better Ninja Script - so forgive the messy way this is done.

setting oif's in indicators is fraught with little niggles

1. You have to send orders to the incoming folder whilst the position is "updated" - I use that term loosely - in the outgoing folder (My Documents -Nt 6.5)

2. I am reading the file in the outgoing folder and checking for when it doesn't say "FLAT" - eventually I will get it to look for long and short but lets walk first.

3.once that happens ( ie I am assuming I have a filled order - again partial fills are not catered for yet) - you can then send a straight oco order to the incoming folder in the format

PLACE;<ACCOUNT>;<INSTRUMENT>;<ACTION>;<QTY>;<ORDER TYPE>;[LIMIT PRICE];[STOP PRICE];<TIF>;[OCO ID];[ORDER ID];[STRATEGY];[STRATEGY ID]

 
Code
 stoporder = "PLACE;SIM101;"+symb()+";SELL;"+roundsizestr+";STOP;;"+stop+";DAY;"
+OCOID+";"+orderid+";;";  
File.AppendAllText(incomingpath",stoporder);	

tgtorder =  "PLACE;SIM101;"+symb()+";SELL;"+roundsizestr+";LIMIT;"+target+";;DAY;"
+OCOID+";"+orderid+";;"; 
File.AppendAllText(incomingpath+"3.txt",tgtorder);
I am only using this in sim so far as there are lots of holes but I am very pleased so far - I can now submit an order and place a stop and a target that are oco - its just annoying I can't use all the built in position code as it's all strategy based - unless someone can tell me otherwise...
btw is anyone finding this useful?

Started this thread Reply With Quote




Last Updated on October 8, 2009


© 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