Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm programming an indicator which sends orders to a strategy through a button on chart. Once in position inserts stoploss and profit target orders in OCO. SL and PT levels are calculated as soon as the entry order is sent and remain active until the order is filled. I'm not using ATM but a simple Strategy that is attached to the chart. Everything works fine with only a single chart, but, when I use it with more charts, the strategy inserts the SL and TP orders only on the first activated strategy. Does anybody faced a trouble like this or has any hints/suggestions for fixing it?
Using a similar concept, I solved most of my problems with a third file containing the outsourced global variables.
This file is placed on a chart that I never chage during the day (weekly chart).Now I can change timeframes when in a trade etc. without resetting the chart values in the charttrader chart. Using multiple strategies, global performance values etc.
This third file did it for me. Hard to guess if this will help with your code.
monpere:
The strategy is interfaced through a Global variable from an indicator, which sends command (ex: "Buy" ) as well as entry level and SL and PT levels. Entry order (in stop) is entered on button pressing, while the exit levels are activated only "On Execution".
If I use a single chart, everything works as expected, but, adding a second chart (different market), on execution of the entry order, TP and SL are not activated.
Strategies are both attached to any of the 2 charts, so I wouldn't see any reason for not working properly.
My idea is that the manual order could generate a bit of confusion and probably the variable should be "restarded".
I've already done a similar code through ATM and it worked, but that's easier because one has to create an ATM for any of the markets. The pity is that I need to have the number of shares/lots variable and this cannot be done with ATM.
terratec:
interesting idea, although my levels need to be changed often. What do you mean with a third file? A new indicator?
NinjaTrader would not support cross communication between instantiated strategy or indicator classes, a turnaround point could be to rename the same strategy for each and every one chart you want to be opened on your workspace.
You have an indicator and a strategy. Somewhere you have to define your global stuff. If doing in the indicator or strategy you will have a problem if you use multiple charts / strategies.
So I use an indicator file (could also be a strategy), to have those declarations only once on my system and untouched for the day. In this file I just have the declarations of the variables, their standard values and some calculations like unrealized and realized P&L for all instruments etc.
All the other stuff like sending commands and feedback goes from indy to the strategy of that instrument and back to indy. The third file ist for declaration (and some extras) only. Code like this:
this way sounds good unless you keep your markets/targets/stops unchanged (it looks like some sort of "plan for that day"), but my semi-automated trading is for intraday, so targets and stops must necessarily be manually changed.
Thanks for the idea, I'll keep in mind for future applications.
I am a scalper and have to decide very quick for a mini, medium or big scalp, or to add a runner. It is the beauty of that system that let me do this.
In the indicator I just have to press a button for the strategy (mini, medium, big I would like, and one for the quantity. (and order type and place) The system will place the stops and targets according to the instrument (calculated from the baseTicks values in the globals). The baseTick values could be calculated by ATR etc. but I use values fitting to my style for each instrument. This way I dont have to change settings in each indicator etc., just in one file. And I only need one indicator and one strategy for all the instruments, plus that third file.
When trading in ES, I can just switch the instrument in the chart to CL and everything is ready...