NexusFi: Find Your Edge


Home Menu

 





MultiChart MA In Easy Language not tying back


Discussion in MultiCharts

Updated
    1. trending_up 3,148 views
    2. thumb_up 3 thanks given
    3. group 1 followers
    1. forum 11 posts
    2. attach_file 1 attachments




 
Search this Thread

MultiChart MA In Easy Language not tying back

  #1 (permalink)
jeremysy
Toronto
 
Posts: 7 since Aug 2013
Thanks Given: 3
Thanks Received: 0

Hi There,

My code below trades based on EMA crosses. When I plot the EMA from the strategy onto the chart the 34 ema doesn't look the same as the 34 ema that is built into MultiCharts under the drawings. Is there something wrong with my code?

Inputs: Price (Close),
Length1(2),
Length2(8),
Length3(34),
Cts (1);

Vars: ExpAv1(0),
ExpAv2(0),
ExpAv3(0);

ExpAv1 = XAverage (Price,Length1);
ExpAv2 = XAverage (Price,Length2);
ExpAv3 = XAverage (Price,Length3);
{Buy or short sell contracts at exponential average crossovers}

If ExpAv1[1] Crosses Above ExpAv2[1] and ExpAv1 > ExpAv2 then
begin
Buy ("Buy")Cts shares next bar at market ;
End;


if Close[1] <= ExpAv2[1] and marketposition>0 then
begin
sell ("Stop Loss")Cts shares next bar at market ;
End;


if Close[1] >= ExpAv3[1] and marketposition>0 then
begin
sell ("Target")Cts shares next bar at market ;
End;


//setstoploss (ExpAv2);
//setprofittarget(ExpAv3);

{If ExpAv1[1] crosses Below ExpAv2[1] and ExpAv1 < ExpAv2 then
begin
sellshort ("ShortSale")CTS shares next bar at market;
End;


setstoploss(ExpAv2) ;
setprofittarget(ExpAv3);}



value97 = text_new(D,T,ExpAv1,"*");
text_SetColor(Value97,CYAN);

value98 = text_new(D,T,ExpAv2,"*");
text_SetColor(Value98,Red);

value99 = text_new(D,T,ExpAv3,"*");
text_SetColor(Value99,Green);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,645 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338

They should be the same functions, but remember that exp avg theoretically includes ALL previous data. So, if your starting points for calculation are different, you will get different results in ema calculations.

I suggest printing out the values in both MC and TS, and then it might be easier to debug.

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
jeremysy
Toronto
 
Posts: 7 since Aug 2013
Thanks Given: 3
Thanks Received: 0


How do I tell it to calculate on more data? I pulled in 80 days and told it to use 50 bars and it is still only running on only 20 bars.

Reply With Quote
  #4 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,645 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


jeremysy View Post
How do I tell it to calculate on more data? I pulled in 80 days and told it to use 50 bars and it is still only running on only 20 bars.

My bad, I thought you were comparing Tradestation and Multicharts results. It sounds like you are comparing Multicharts Analysis (Plot) with Multicharts Strategies.

I do not use MC, but maybe showing you how Tradestation does it will help...

In Tradestation, if you go to Format Analysis technique, you can adjust the number of bars a study references.


Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
jeremysy
Toronto
 
Posts: 7 since Aug 2013
Thanks Given: 3
Thanks Received: 0

Your first reply helped me figure it out actually. I changed the max bars back and it worked out. You know anything about candlestick trading? I'm trying to add bullish engulfings as a requirement for entry in this strategy any ideas?

Reply With Quote
  #6 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,645 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


jeremysy View Post
Your first reply helped me figure it out actually. I changed the max bars back and it worked out. You know anything about candlestick trading? I'm trying to add bullish engulfings as a requirement for entry in this strategy any ideas?

The bull/bear engulf code I have I did not write, so I can't post it here. Does MC possibly have an engulfing function built in?

Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
jeremysy
Toronto
 
Posts: 7 since Aug 2013
Thanks Given: 3
Thanks Received: 0

It does but I can't figure out how to use it in my code. The code for the engulfing function is :

Inputs: Len(Numeric);
condition1 = Average(Close, Len) < Average(Close, Len)[1] AND Close > Open AND Close[1] < Open[1]
AND Close > Open[1] AND Open < Close[1];
If condition1 Then
BullishEngulfing = True
Else
BullishEngulfing = False;

Reply With Quote
  #8 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,645 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


jeremysy View Post
It does but I can't figure out how to use it in my code. The code for the engulfing function is :

Inputs: Len(Numeric);
condition1 = Average(Close, Len) < Average(Close, Len)[1] AND Close > Open AND Close[1] < Open[1]
AND Close > Open[1] AND Open < Close[1];
If condition1 Then
BullishEngulfing = True
Else
BullishEngulfing = False;


So stick the above calcs earlier in your code. Then, when you get to order placement part of code:

"If ExpAv1[1] Crosses Above ExpAv2[1] and ExpAv1 > ExpAv2 then "

change it to this if you want to go long only when bull eng is true

If ExpAv1[1] Crosses Above ExpAv2[1] and ExpAv1 > ExpAv2 and BullishEngulfing=True then

Follow me on Twitter Reply With Quote
  #9 (permalink)
jeremysy
Toronto
 
Posts: 7 since Aug 2013
Thanks Given: 3
Thanks Received: 0

For some reason that doesn't work. I was trying that and it gives me a "Casual Study: (Function)" errror

Reply With Quote
  #10 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,645 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338



jeremysy View Post
For some reason that doesn't work. I was trying that and it gives me a "Casual Study: (Function)" errror

Try changing BullishEngulfing and BearishEngulfing to BullEng and BearEng and then define them

var: BullEng(False), BearEng(False);

Follow me on Twitter Reply With Quote




Last Updated on August 15, 2013


© 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