NexusFi: Find Your Edge


Home Menu

 





VIDEO TUTORIAL: How to create an advanced MultiCharts EasyLanguage Strategy


Discussion in MultiCharts

Updated
      Top Posters
    1. looks_one ABCTG with 7 posts (3 thanks)
    2. looks_two Big Mike with 6 posts (82 thanks)
    3. looks_3 andby with 3 posts (1 thanks)
    4. looks_4 spinnybobo with 2 posts (0 thanks)
      Best Posters
    1. looks_one Big Mike with 13.7 thanks per post
    2. looks_two Lampert with 3.5 thanks per post
    3. looks_3 Family Trader with 2 thanks per post
    4. looks_4 ABCTG with 0.4 thanks per post
    1. trending_up 68,262 views
    2. thumb_up 97 thanks given
    3. group 36 followers
    1. forum 42 posts
    2. attach_file 16 attachments




 
Search this Thread
  #1 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597

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:


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.

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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My Rant with AMP Futures
Trading Reviews and Vendors
[WTS] ATAS Lifetime ULTRA license – EU buyers only – …
Platforms and Indicators
EA
Platforms and Indicators
No book, only a stair: journaling fills where price move …
Cryptocurrency
I developed a free AI-powered (Kronos) forecasting indic …
The Elite Circle
 
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597

Here is the code for jtHMA function if you need it:

 
Code
                            


{jtHMA - Hull Moving Average Function}
{
Author: Atavachron}
{
May 2005}

Inputs: price(NumericSeries), length(NumericSimple);
Vars: halvedLength(0), sqrRootLength(0);

{
Original equation is:
---------------------
waverage(2*waverage(close,period/2)-waverage(close ,period), SquareRoot(Period)
Implementation below is more efficient with lengthy Weighted Moving Averages.
In addition, the length needs to be converted to an integer value after it is halved and
its square root is obtained in order for this to work with Weighted Moving Averaging
}

if ((
ceiling(length / 2) - (length / 2)) <= 0.5) then
halvedLength 
= ceiling(length / 2)
else
halvedLength = floor(length / 2);

if ((
ceiling(SquareRoot(length)) - SquareRoot(length)) <= 0.5) then
sqrRootLength 
= ceiling(SquareRoot(length))
else
sqrRootLength = floor(SquareRoot(length));

Value1 = 2 * WAverage(price, halvedLength);
Value2 = WAverage(price, length);
Value3 = WAverage((Value1 - Value2), sqrRootLength);

jtHMA = Value3; 
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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597


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).

 
Code
                            


{
Big Mike Trading https://nexusfi.com
June 2011
}


inputs:
    
smalength ( 200 ),
    
emalength ( 100 ),
    
hmalength ( 34 ),
    
target1 ( 12 ),
    
target2 ( 12 ),
    
target3 ( 20 ),
    
stopsize ( 12 ),
    
BE2 ( 0 ), // 0=false, 1=true
    
BE3 ( 0 ); // 0=false, 1=true
    
vars:
    
TickSize    ( MinMove / PriceScale ),
    
smav        ( 0 ),
    
emav        ( 0 ),
    
hmav        ( 0 ),
    
t1        ( Target1 * TickSize ),
    
t2        ( (Target1 + Target2) * TickSize ),
    
t3        ( (Target1 + Target2 + Target3) * TickSize ),
    
st1        ( 0 ),
    
st2        ( 0 ),
    
st3        ( 0 );
    
smav = Average(Close, smalength);
emav = XAverage(Close, emalength);
hmav = jtHMA(Close, hmalength);


// open new positions

if MarketPosition = 0 then begin

    
if smav > smav[1] and emav > emav[1] and hmav > hmav[1] then begin
    
        Buy 
("Enter long") 3 Contracts Next Bar At Market;
    
    
end; 

    if 
smav < smav[1] and emav < emav[1] and hmav < hmav[1] then begin
    
        SellShort 
("Enter short") 3 Contracts Next Bar At Market;
    
    
end; 
end;

// manage open orders

if MarketPosition = 1 then begin

    st1 
= EntryPrice - (stopsize * TickSize);
    
st2 = iff(BE2 = 1, EntryPrice, EntryPrice - (stopsize * TickSize));
    
st3 = iff(BE3 = 1, EntryPrice, EntryPrice - (stopsize * TickSize));
    
    if 
CurrentContracts = 1 then begin
        Sell 
("Exit l3-c1 Target") 1 Contracts Next Bar At (EntryPrice + t3) Limit;
        
Sell ("Exit l3-c1 Stop") 1 Contracts Next Bar At st3 Stop;
    
end;

    if 
CurrentContracts = 2 then begin
        Sell 
("Exit l2-c2 Target") 1 Contracts Next Bar At (EntryPrice + t2) Limit;
        
Sell ("Exit l2-c2 Stop") 1 Contracts Next Bar At st2 Stop;
        
Sell ("Exit l3-c2 Target") 1 Contracts Next Bar At (EntryPrice + t3) Limit;
        
Sell ("Exit l3-c2 Stop") 1 Contracts Next Bar At st3 Stop;
    
end;
    
    if 
CurrentContracts = 3 then begin
        Sell 
("Exit l1-c3 Target") 1 Contracts Next Bar At (EntryPrice + t1) Limit;
        
Sell ("Exit l1-c3 Stop") 1 Contracts Next Bar At st1 Stop;
        
Sell ("Exit l2-c3 Target") 1 Contracts Next Bar At (EntryPrice + t2) Limit;
        
Sell ("Exit l2-c3 Stop") 1 Contracts Next Bar At st2 Stop;
        
Sell ("Exit l3-c3 Target") 1 Contracts Next Bar At (EntryPrice + t3) Limit;
        
Sell ("Exit l3-c3 Stop") 1 Contracts Next Bar At st3 Stop;
    
end;
end;

if 
MarketPosition = -1 then begin

    st1 
= EntryPrice + (stopsize * TickSize);
    
st2 = iff(BE2 = 1, EntryPrice, EntryPrice + (stopsize * TickSize));
    
st3 = iff(BE3 = 1, EntryPrice, EntryPrice + (stopsize * TickSize));
    
    if 
CurrentContracts = 1 then begin
        BuyToCover 
("Exit s3-c1 Target") 1 Contracts Next Bar At (EntryPrice - t3) Limit;
        
BuyToCover ("Exit s3-c1 Stop") 1 Contracts Next Bar At st3 Stop;
    
end;

    if 
CurrentContracts = 2 then begin
        BuyToCover 
("Exit s2-c2 Target") 1 Contracts Next Bar At (EntryPrice - t2) Limit;
        
BuyToCover ("Exit s2-c2 Stop") 1 Contracts Next Bar At st2 Stop;
        
BuyToCover ("Exit s3-c2 Target") 1 Contracts Next Bar At (EntryPrice - t3) Limit;
        
BuyToCover ("Exit s3-c2 Stop") 1 Contracts Next Bar At st3 Stop;
    
end;
    
    if 
CurrentContracts = 3 then begin
        BuyToCover 
("Exit s1-c3 Target") 1 Contracts Next Bar At (EntryPrice - t1) Limit;
        
BuyToCover ("Exit s1-c3 Stop") 1 Contracts Next Bar At st1 Stop;
        
BuyToCover ("Exit s2-c3 Target") 1 Contracts Next Bar At (EntryPrice - t2) Limit;
        
BuyToCover ("Exit s2-c3 Stop") 1 Contracts Next Bar At st2 Stop;
        
BuyToCover ("Exit s3-c3 Target") 1 Contracts Next Bar At (EntryPrice - t3) Limit;
        
BuyToCover ("Exit s3-c3 Stop") 1 Contracts Next Bar At st3 Stop;
    
end;
    
end; 
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
Attached Files
Elite Membership required to download: BMT_MoneyMaker.pla
Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597

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.

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
Attached Thumbnails
Click image for larger version

Name:	6-4-2011 4-15-15 PM.png
Views:	759
Size:	224.9 KB
ID:	40201   Click image for larger version

Name:	6-4-2011 4-17-11 PM.png
Views:	722
Size:	21.3 KB
ID:	40202   Click image for larger version

Name:	6-4-2011 4-18-12 PM.png
Views:	871
Size:	158.0 KB
ID:	40203   Click image for larger version

Name:	6-4-2011 4-18-59 PM.png
Views:	781
Size:	50.1 KB
ID:	40204   Click image for larger version

Name:	6-4-2011 4-19-55 PM.png
Views:	776
Size:	11.3 KB
ID:	40205   Click image for larger version

Name:	6-4-2011 4-20-05 PM.png
Views:	795
Size:	17.4 KB
ID:	40206   Click image for larger version

Name:	6-4-2011 4-20-19 PM.png
Views:	685
Size:	27.2 KB
ID:	40207   Click image for larger version

Name:	6-4-2011 4-21-27 PM.png
Views:	736
Size:	77.8 KB
ID:	40208  
Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597

Feel free to make a request for future video tutorials in this thread.

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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #6 (permalink)
 Family Trader 
Palm Beach County
 
Experience: Advanced
Platform: OEC about to change to Ninja
Trading: ES ,EUR/USD
Posts: 179 since Feb 2011
Thanks Given: 66
Thanks Received: 90

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.

Hope your hand/wrist are healing well..

Trader


Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
 steelchueh 
Taipei/Taiwan
 
Experience: Beginner
Platform: Multicharts/NinjaTrader
Broker: AMP/CQG
Trading: ES
Posts: 42 since Oct 2011
Thanks Given: 139
Thanks Received: 25


Big Mike View Post
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.

Mike

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...

-Steel


Reply With Quote
  #8 (permalink)
erchis
Plzeň
 
Posts: 3 since May 2012
Thanks Given: 0
Thanks Received: 0

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


Reply With Quote
  #9 (permalink)
erchis
Plzeň
 
Posts: 3 since May 2012
Thanks Given: 0
Thanks Received: 0

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?

Thanks very much

CODE:
---------------------------------------------------------------------------------------------------------------
inputs:

smalength ( 26 ),

emalength ( 8 ),

macdfastlength ( 5 ),

macdslowlength ( 10 ),

ccilength (14);



vars:

TickSize ( MinMove / PriceScale ),

smav ( 0 ),

emav ( 0 ),

macdv ( 0 ),

cciv ( 0 ),

money ( 70000 ),

stocks ( Close/money ),

tar ( 0 ),

st ( Close ),

timer ( 0 );



smav = Average(Close, smalength);

emav = XAverage(Close, emalength);

macdv = MACD(Close, macdfastlength , macdslowlength);

cciv = CCI(ccilength);


// open new positions


if MarketPosition = 0 then begin


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;

end;


Reply With Quote
  #10 (permalink)
 guppy 
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
Posts: 52 since Aug 2011
Thanks Given: 11
Thanks Received: 8


Hi Mike,

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?




Big Mike View Post
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.

Mike


Reply With Quote




Last Updated on August 2, 2021


© 2026 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 - Downloads - Top
no new posts