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)
Last year I did a video tutorial on creating an advanced NinjaTrader strategy, and you guys liked it. So I thought that since I don't use NT any more it would be a good idea to do the same strategy as an example in EasyLanguage with MultiCharts.
First, here is a link to the NinjaTrader Video Tutorial:
In this video tutorial I show how to create a strategy from scratch (not using the wizard, which I never use).
The strategy contains a few optimizable parameters such as SMA length, EMA length, HMA length, three different targets with custom tick settings …
OK, so in this video I show you how to create a strategy with optimizable parameters such as SMA length, EMA length, HMA length, three different targets, a stop, and the option to move target 2 to breakeven after target 1 is hit, as well as an option to move target 3 to breakeven after target 2 is hit.
Remember, this strategy is just an example! It took only a few minutes to write, and even though it shows to be profitable - it isn't (it won't be). Simple strategies are usually best to avoid curve fitting, but this one is too simple to actually work fully automated. A good strategy may take dozens of hours to create.
This example was created just so you could get your feet wet and learn some of the basics of strategy creation in MultiCharts or EasyLanguage.
Here is the code for the strategy created in our video example. I've also attached a MultiCharts pla to make it easy for importing, and that pla also contains the jtHMA function (since HMA is not built-in to MultiCharts).
Here is a follow-up. This is a 1-year backtest on the EUR/USD, 6 range chart, with $2 commission per side and $12.50 slippage per contract.
Results came back with 28k net profit on 2,159 trades, 40% win rate, w/l ratio of 1.56. However, when you look at the equity curve and other performance metrics, you'll see this strategy needs work. As expected. This video was just an example, you could use it as a starting point.
Thank you for the presentation....very useful to a 'dumb techy' like me...worth a laugh when you apologized for having to type 'slow'...in comparison to the Ninja video where I had to hit the "pause" button a million times to follow what you were doing.
Very good to show me for the multiple contracts control in the MC..
Well, the MDD seems quite huge... for such strategy...
Thanks for your sharing, anyway,, I learned a lot!!
Wish for sharing more MC coding examples...
Hi Big Mike,
could you help me please with writing this simple strategy in EasyLanguage?
Strategy:
Indicators - EMA(x), SMA(y), MACD(m,n,o), CCI(p); where x<y
Our pozition is everytime e.g. 5 % of 100000$ - initial capital.
Bull's position:
Signal for entry- EMA(x) crosses up SMA(y), where x<y, and MACD>=0 ∧ CCI>=0
Moment of entry - closing price of the candle, in which crossover hapend
STOPLOSS - minimum of the candle, which is the lowest in recent x days, where x is EMA's period, (I think it is called SWING LOW) and it moves with time
PROFIT TARGET - is in the same distance like STOPLOSSE every time and when we achieve it, we close half amount of our position
Signal for exit- EMA(x) crosses down SMA(y), where x<y, in this moment we sell the second half of position or whole position in that case we didn't achieve PROFIT TARGET yet.
Bear's position
the rules are same but vice versa
That's it and I have also one suggestion for next video tutorial - how backtest portfolio in MultiCHarts
Thank you for any help
and I'm sorry for my bad English
Hi,
I wrote some code according to the video and my trading rules above and tried it
on day chart of google, but it doesn't make any trades...is the algorithm correct?
if emav crosses over smav then begin
alert("prekrizeni nahoru");
if macdv >= 0 and cciv >= 0 then begin
Buy ("Enter long") stocks Contracts Next Bar At Market;
end;
end;
if emav crosses under smav then begin
if macdv < 0 and cciv < 0 then begin
SellShort ("Enter short") stocks Contracts Next Bar At Market;
end;
end;
end;
// manage open orders
if MarketPosition = 1 then begin // 1 - means long position opened
for timer = 0 to emalength - 1 begin
if st > Close[timer] then begin
st = Close[timer]; // stoploss on the swing low
end;
end ;
tar = Close + (Close - st);
Sell ("Exit long Target") stocks/2 Contracts Next Bar At tar Limit;
Sell ("Exit long Stop") currentcontracts Contracts Next Bar At st Stop;
end;
if MarketPosition = -1 then begin // -1 - means short position opened
for timer = 0 to emalength - 1 begin
if st < Close[timer] then begin
st = Close[timer]; // stoploss on the swing high
end;
end ;
tar = Close - (st - Close);
BuyToCover ("Exit short Target") stocks/2 Contracts Next Bar At tar Limit;
BuyToCover ("Exit short Stop") currentcontracts Contracts Next Bar At st Stop;
In your example, what if your profit or stop loss gets hit on the entry bar. How can you make it so that it will exit on the entry bar and not on the next bar?