Setting up a strategy: confused with all the methods - futures io
futures io



Setting up a strategy: confused with all the methods


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Trader.Jon with 7 posts (2 thanks)
    2. looks_two wown with 5 posts (0 thanks)
    3. looks_3 baruchs with 4 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,968 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 17 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Setting up a strategy: confused with all the methods

(login for full post details)
  #1 (permalink)
wown
Boston
 
 
Posts: 21 since Nov 2010
Thanks: 0 given, 17 received

Hi guys,

A little background:

I have spent the last few months coding and testing a couple of indicators created by Tom Demark (I would post a link but the forum wont let me please google it). Specifically, I have managed to code the Setup, Combo, and Sequential in ninjatrader.

Now, I want to automate the trading (or at least backtest it) so that I can trade a strategy based on these indicators. In short here is the strategy (works for either direction, long or short. I will explain the long side):
1. When any 2 of indicators (setup or combo or sequential) are completed within 5 bars of each other, a buy signal is ready.
2. Calculate targets 1, 2 and a stop loss. basically, take 33,50,61, 23) retracements for the two completed sub-signals.
compare the 33,50,and 61 retarcements between the two sub-signals and figure out which two retracements are the closest (see pictures below). the lower of the two smallest differences is target 1, while the higher is target 2. Stop loss is the 23% retracement average for the two sub-signals.
I have everything up to here coded.

3. So, I want to enter long when my buy signal is ready. i will enter long with target 1,2 and stop loss when the ask price is more than the close/open (whichever is higher) of the previous bar. i want to keep the order open for 5 bars then cancel the order and basically forget about this signal.
4. once i enter, i want to
a: sell 25% at target 1 and move stop loss to B/E
b: sell 50% at target 2, and move stop loss to target 1
c: if price moves beyond the high of any of the sub signals (already calculated), start a trailstop loss with some amount (for the sake of argument, lets say 10% of the range of the subsignal exceeded - can be easily caluclated).
d: and of course sell all if we go to stop loss.

As I said, I have already coded points 1 and 2. But I am highly confused by how to manage my orders in the way described above. Ideally, I want to be able to optimize and see what settings work best (for example sell 50% at target 1, etc). I would really appreciate it if I can get some guidance on how to code the above points 3 and 4. I would be happy to share the indicators with you if you are interested if you can help me code my strategy.

I have included some pictures on my blog (stockjockz.blogspot.com/2011/03/strategy-definition.html) to show what I intend to do.

Thanks a lot!

Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(76 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(23 thanks from 5 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(15 thanks from 8 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Becoming a day trader (PA, volume profile, footprint etc.)by JirkaF
(0 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
71 thanks
Would You Sell Your System?
65 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
30 thanks
Big Mike in Ecuador
25 thanks
 
(login for full post details)
  #3 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received


Hi,
I just want to advise you to code any strategy with only one target.
In your case code 3 variants of your strategy. One for each PT. Then see if each is a profitable strategy. (My guess is that not), then you can combine them or just trade 3 strategies.

Baruch

Reply With Quote
 
(login for full post details)
  #4 (permalink)
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
 
bnichols's Avatar
 
Posts: 638 since Feb 2010
Thanks: 64 given, 460 received

I found Big Mike's Hurley9_5 and MWinfrey's GenericStrategy_v1 (available to Elite members) very instructive as templates for order management.

P.S. I don't intend to influence anyone one way or another about Elite membership but for me it's proven worthwhile.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #5 (permalink)
wown
Boston
 
 
Posts: 21 since Nov 2010
Thanks: 0 given, 17 received


Quoting 
Hi,
I just want to advise you to code any strategy with only one target.
In your case code 3 variants of your strategy. One for each PT. Then see if each is a profitable strategy. (My guess is that not), then you can combine them or just trade 3 strategies.

Baruch

I am not sure how would you structure that. You will have 3 independant strategies, execute them all at the same time?? I am confused.
Also, when you say "my guess is that not", i assume you are referring to the strat? why do u say that?

thanks

Reply With Quote
 
(login for full post details)
  #6 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received


Quoting 
I am not sure how would you structure that. You will have 3 independant strategies, execute them all at the same time?? I am confused.
Also, when you say "my guess is that not", i assume you are referring to the strat? why do u say that?

Let say that your strategy gives 4K a month. Its a good result, even very good. But now you examine each setup separately and you see that setup with a smallest target end with -2K, the setup with the second target ends with -1K. What is the result of a biggest target? What will you do? Continue the same? You need to know this!
So yes first test each target separately and if each is profitable you can combine them into one strategy or trade 3 strategies together.
Please, after you code your strategy that way and all 3 targets are profitable, post the results here and I'll eat my hat.

Baruch

Reply With Quote
 
(login for full post details)
  #7 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


baruchs View Post
Let say that your strategy gives 4K a month. Its a good result, even very good. But now you examine each setup separately and you see that setup with a smallest target end with -2K, the setup with the second target ends with -1K. What is the result of a biggest target? What will you do? Continue the same? You need to know this!
So yes first test each target separately and if each is profitable you can combine them into one strategy or trade 3 strategies together.
Please, after you code your strategy that way and all 3 targets are profitable, post the results here and I'll eat my hat.

Baruch

Baruch,

I dont want to eat hat, but I am interested in your response to my perspective of market activity.

I have been backtesting and SIM a strategy with 3 targets: PT1 and PT 2 are hard coded targets and PT3 is a 'runner' with a maximum target. Runner is referencing that there is a trailing code setup, besides the hard code stoploss. PT 1 and PT2 are taken out by the stoploss, or traget hit, or an exit algorithm based on 3 indicators. This is not the final setup, just example of looking at the distribution of targets and backtested profit values.

Optimization based on two months data, and out of sample test without changeing parameters is 10 months.

Using EURUSD as an example, PT1 of 7 pips target x 10000 euro = 38% of profit acheived
and PT2 of 12pips target x 10000 euro = 35% of profit acheived
and PT3 of 40pips target x 10000 euro = 27% of profit acheived

The '% of profit achieved' was done in place on one strategy with 3 targets: with the currency settings in NT7 I would plug-in a value of '1' for PT2 and PT3 and the 10000 for PT3 to get the representative values for PT3 etc etc.
'Eyeballed' moneymanagement would likely give about a ratio of PT1 == 50-60000 euro, PT2 == 20-30000 euro and PT3 10-20000 euro on an 'average' day.

My feeling on all this is that there is more gained by having the 3 targets together as a help in not taking a lot of trades during non-profitable market chop sessions. Running PT2 alone is MORE profitable when all 30000 euro are applied to the target, and also has more consecutive losing trades, and also many more entries so there is some degree of added risk to use of that scenario (that statement is based on NOT re-optimizing on just the PT2 !). PT3 has same entry as PT1/2, but effectively is a different strategy because it has a longer term target and a trailing stop instead of the exit rules PT1/2 have. PT3 is less profitable that the combination of PT123 when all 30000 euro is applied to that target, but also has many fewer trades and as a result less likehood of as much slippage accumulation.

Different markets = different potentials. Different market activity, day to day, can be acknowledged within the same overal strategy. You like a basket of markets, I like a basket of strategys for 1 market (at least for now).

I am about to add 2 more targets that will use partially the entry rules that PT123 already use, but different trailing and exit conditions. Challenging, and time consuming, unfortunately lol

Regards,
TJ

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
(login for full post details)
  #8 (permalink)
wown
Boston
 
 
Posts: 21 since Nov 2010
Thanks: 0 given, 17 received

Tj- that sounds a lot like what i want to do. I think i would agree with uin saying one 1 target by itself wud probably not be profitable. In any case- aint nothin like testin it out myself.

Tj- could you provide some guidance on how you set that up?

Reply With Quote
 
(login for full post details)
  #9 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


wown View Post
Tj- that sounds a lot like what i want to do. I think i would agree with uin saying one 1 target by itself wud probably not be profitable. In any case- aint nothin like testin it out myself.

Tj- could you provide some guidance on how you set that up?

What do you specifically need to know ... and have you checked out the strategies available in the Elite downloads?

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
(login for full post details)
  #10 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received


Hi TJ,
First I want to say that what you did, by testing each PT, is very good. If those are the results then of course do it like this. My point was that you need to test each target if it contributes to your profit or not.
Still I'm very skeptical about this approach. As you said I think that the biggest strength of automation is multi. Multi strategies/instruments/time frames.
The benefit of this is that because of lower correlation of the outcomes your draw down shrinks.
As you know I even demonstrated that with two absolutely negatively correlated strategies (correlation=-1) it can be beneficial to add a loosing strategy to a wining one.
Again the main issue is outcome correlation! Not instruments correlation, not time frame correlation.
I showed an actual beck test of one strategy on 20 different instruments with same parameters on same time frame. Apparently their outcome correlation was very small, hence the results.
Now lets check multi target approach in this sense. Lets do it with only 2 targets. I'm certain that you'll be able to extrapolate it to 3, 4 or 10 targets.
The possible outcomes of strategy with 2 targets:
1. Bigger target is met - then smaller is met too. Correlation 1.
2. Smaller target is not met (hit the stop) - bigger target is not met too. Correlation 1.
3. Smaller target is met, stop is moved to BE and second target not met. Correlation 0.
So you see in this approach the outcome correlation is too high. It is still smaller than 1. So go ahead and trade it.

Baruch,
p.s.
If you read my thread and saw my excel sheet, I told that the results are not correct. They were not correct because that test was on currency pairs, but done only on last (bid) price. When I added the ask price series the results were much worse. I hope you took this into your consideration.

Reply With Quote
 
(login for full post details)
  #11 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


baruchs View Post
Hi TJ,
...If you read my thread and saw my excel sheet, I told that the results are not correct. They were not correct because that test was on currency pairs, but done only on last (bid) price. When I added the ask price series the results were much worse. I hope you took this into your consideration.

baruchs,

Honestly, I have not given that a great deal of consideration. The spread between Bid / Ask on EURUSD is small enough IMHO that calculating it into an automated strategy is non-beneficial.

What I see as the 'time to fill' (chart closes bar >> calculates that there is an entry >> sends order entrylonglimit (ask, closes, last, whatever) on a fast market overcomes any tests that were done in hindsight. Even a 3 pip margin added to an ask(0) or closes[0][0] target price can leave it unfilled on the next bar, regardless of which direction OR directions the next bar went. I have seen that often in the unregulated currency markets.

If you can get your orders filled 100% of the time at the price you want, immediately, I would certainly appreciate the sharing of that knowledge (ie HOW do you do it?). My best 'hat eating' guess would be that the fill success rate on the next bar for the exact price targeted will be somewhat closer to 35-50% than it is to 65-70%.

Regards,
Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
(login for full post details)
  #12 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


baruchs View Post
Hi TJ,
...
Now lets check multi target approach in this sense. Lets do it with only 2 targets. I'm certain that you'll be able to extrapolate it to 3, 4 or 10 targets.
The possible outcomes of strategy with 2 targets:
1. Bigger target is met - then smaller is met too. Correlation 1.
2. Smaller target is not met (hit the stop) - bigger target is not met too. Correlation 1.
3. Smaller target is met, stop is moved to BE and second target not met. Correlation 0.
So you see in this approach the outcome correlation is too high. It is still smaller than 1. So go ahead and trade it.
.

In my strategy, adjusted for 2 targets, :: smaller target not met (exited via conditional rule set) - bigger target not met either but is closed out at a higher price via the trailing rules conditions. OR it could be hitting its maximal target. There is no BE stop.

What is the correlation with the scenario? Would you trade it?

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
(login for full post details)
  #13 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received

Tj,
I'm sorry its not you its me, but I don't understand your points.

Quoting 
In my strategy, adjusted for 2 targets, :: smaller target not met (exited via conditional rule set) - bigger target not met either but is closed out at a higher price via the trailing rules conditions. OR it could be hitting its maximal target. There is no BE stop.

What is the correlation with the scenario? Would you trade it?

Do you want me to guess? You can just dump the trades into excel and apply a correlation function.
My point is that it will be much bigger than with 2 strategies or the same strategy on 2 instruments.
If you think its good for you then trade it no question.

Quoting 
If you can get your orders filled 100% of the time at the price you want, immediately, I would certainly appreciate the sharing of that knowledge (ie HOW do you do it?). My best 'hat eating' guess would be that the fill success rate on the next bar for the exact price targeted will be somewhat closer to 35-50% than it is to 65-70%.

Again whats your point?
I would not bother with coding strategies if its not possible to backtest them with at least 90% accuracy to live.
On one hand you say bid/ask backtesting is not important and on the other that your accuracy is below 50%.

Baruch

Reply With Quote
The following user says Thank You to baruchs for this post:
 
(login for full post details)
  #14 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received

Baruch,

I have never had a 'handle' on Excel or Lotus123 or any other spreadsheet ... just too much to learn already in NT ... so I am just using what I can with NT, including studying the charts after backtests and optimizations and my written notebooks. Definitely limiting, and does have a an actual calming effect on not having extremely too much information.

No, I think it is me, so I will try to rephrase. I have a sincere admiration for any trader that can get fills on their orders at the price they want, WHEN they want. I dont see it happening like it should in SIM, and it was never happened above about 65% of the time in my live trades (NQ, YM, ES, 6E). I am not talking about stops or targets, I am speaking to filling the order.

I currently run the automated strategy (COBC=true) in SIM, EURUSD on MB Trading and Dukascopy, and the orders are placed and marked by the strategy, ie EnterLongLimit true,Closes[0][0] + (2 or 3) ticks, and often (lets say 50% of time) I can watch the bar move up and down around the target price with never getting a fill. I didnt design to 'chase' the price on a long if it moves up unless the strategy still gives a buy signal on a subsequent bar: this doesnt happen very often unless the market is choppy: I still have to add code to exit the order if not filled in two bars. IF the order filled on the entry bar at a target price as calculated, 65% of time it is profitable. Looking at those trigger marks on the chart, I surmise that 65% of them would have been profiatble as well, if they had been filled.

>>>>>>>>>>>>>> So, what is the 'tool' needed in the strategy to get GOOD fills? I dont want to use market orders as they more often than not get a fill price beyond my initial target, actually getting me into loss mode, and it is psychologically troublesome when I see that happen. <<<<<<<<<<<<

Today I made a decision to revamp my strategy innards to get everything working/calculation based solely on BIP=0 and the indicators are modified to work on the the different BIPs internally within the indicator itself. I am moving from BIP=0 5 Better Renko to somewhere between 1 and 3 ticks bar. I am anticipating/hoping this will giving me the same overall results that the original strategy did, as I use only 3 different indicators in entry conditions and 4 in the trailing/exit codes.

Feedback is appreciated,
Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
The following user says Thank You to Trader.Jon for this post:
 
(login for full post details)
  #15 (permalink)
wown
Boston
 
 
Posts: 21 since Nov 2010
Thanks: 0 given, 17 received

well, lol, it seems we have drifted off topic a bit. All interesting stuff though.

anyway, I think I now understand what baruch was getting at on how to set up the strategies.

however, going back to my original question: what is the code/structure for setting up strategies. disregard the fact that this may be the worst strategy ever designed. my programming knowledge is very limited and I just want to learn the code so i can start at least developing the strategies.

but having done some research i think this is what i have to do (and for sake of simplicity, lets say I have 2 profit targets and 1 stop loss. Each profit target to take 1 /ES contract for example.):

define 2 strategies and trade them at the same time.
strat 1: profit target 1 and stop loss trades 1 /ES.
strat 2: profit target 2 trade 1 /ES. initial stop loss is at the original stop loss. when the price has moved up to strat 1's profit target, move the stop loss to that profit target or BE or whatever.

so, how do i code that?

Reply With Quote
 
(login for full post details)
  #16 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


wown View Post
well, lol, it seems we have drifted off topic a bit. All interesting stuff though.

anyway, I think I now understand what baruch was getting at on how to set up the strategies.

however, going back to my original question: what is the code/structure for setting up strategies. disregard the fact that this may be the worst strategy ever designed. my programming knowledge is very limited and I just want to learn the code so i can start at least developing the strategies. ...so, how do i code that?

wown,

Writing code is an adventure in itself ... have you had a look at the strategies that are available for download here on futures.io (formerly BMT) and also the NT forums?
Links and Downloads Manager - NinjaTrader Support Forum


Study the code in the strategys for a day or two and you will start to get an idea of the sequence and what the structure is. F1 help isnt luxurious with example code but it is useful to get a feeling what each part of the code does when you see it in a completed strategy.

Let us know how you progress and ask questions about specifics as general questions can be more suitable for a hands-on education and not so productive for slow typists like myself.

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
The following user says Thank You to Trader.Jon for this post:
 
(login for full post details)
  #17 (permalink)
wown
Boston
 
 
Posts: 21 since Nov 2010
Thanks: 0 given, 17 received

Thanks TJ. That is kind of what I needed. I actually did not realize that you can download all those strats from NT forums (should have checked). Time to begin reading and running those strats in debug mode

Reply With Quote
 
(login for full post details)
  #18 (permalink)
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


wown View Post
Thanks TJ. That is kind of what I needed. I actually did not realize that you can download all those strats from NT forums (should have checked). Time to begin reading and running those strats in debug mode

In that case, also put this in your favs:
NinjaScript Educational Resources - NinjaTrader Support Forum

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Setting up a strategy: confused with all the methods


Last Updated on March 9, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts