NexusFi: Find Your Edge


Home Menu

 





MULTICHART CODING


Discussion in MultiCharts

Updated
    1. trending_up 3,569 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 gfdaniels 
Roswell
 
Experience: Intermediate
Platform: Multicharts
Trading: es tf ym nq
Posts: 10 since Jul 2015
Thanks Given: 0
Thanks Received: 0

dOES ANYONE HAVE ANY CODE THAT I CAN ADD TO MY THREE EXP AVERAGE STATEGEY TO NOT INITIATE A TRADE UNLESS IT IS ABOVE OR BELOW THE 50 EMA?. THIS IS FOR MY AUTOTRADING STATEGY ALSO HOW TO ADD A TIMEFRAME IT CAN TRADE.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
No book, only a stair: journaling fills where price move …
Cryptocurrency
Datafeed for Atas
Platforms and Indicators
EA
Platforms and Indicators
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
My Rant with AMP Futures
Trading Reviews and Vendors
 
  #2 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 691


gfdaniels View Post
dOES ANYONE HAVE ANY CODE THAT I CAN ADD TO MY THREE EXP AVERAGE STATEGEY TO NOT INITIATE A TRADE UNLESS IT IS ABOVE OR BELOW THE 50 EMA?. THIS IS FOR MY AUTOTRADING STATEGY ALSO HOW TO ADD A TIMEFRAME IT CAN TRADE.

Please turn off the Capslock. Then post the code you already have so we can take a look at it. Bonus points if you clarify your question.


Reply With Quote
  #3 (permalink)
 gfdaniels 
Roswell
 
Experience: Intermediate
Platform: Multicharts
Trading: es tf ym nq
Posts: 10 since Jul 2015
Thanks Given: 0
Thanks Received: 0


inputs: Price( Close ), FastLength(4 ), MedLength(5 ), SlowLength(8) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = XAverage( Price, FastLength ) ;
var1 = XAverage( Price, MedLength ) ;
var2 = XAverage( Price, SlowLength ) ;

Condition1 = Price < var0 and var0 < var1 and var1 < var2 ;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if condition2
then
Sell Short ( "MA3CrsSE" ) next bar at market

inputs: Price( Close ), FastLength(4), MedLength( 5), SlowLength(8) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = XAverage( Price, FastLength ) ;
var1 = XAverage( Price, MedLength ) ;
var2 = XAverage( Price, SlowLength ) ;

Condition1 = Price > var0 and var0 > var1 and var1 > var2 ;

condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if condition2
then
Buy ( "MA3CrsLE" ) next bar at market ;


Started this thread Reply With Quote
  #4 (permalink)
 gfdaniels 
Roswell
 
Experience: Intermediate
Platform: Multicharts
Trading: es tf ym nq
Posts: 10 since Jul 2015
Thanks Given: 0
Thanks Received: 0

I just want to add to not take a trade short if price is above the 50 ema and vice versa


Started this thread Reply With Quote
  #5 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 691


gfdaniels View Post
I just want to add to not take a trade short if price is above the 50 ema and vice versa

I assumed that your `SlowLength` input is manually set to 50 since I couldn't find an EMA 50. Here I just added the condition that compares the `Close` value against the `var2` variable, which holds the EMA of the `SlowLength` period:

 
Code
Inputs: 
	Price( Close ), FastLength(4 ), MedLength(5 ), SlowLength(8) ;

variables: 
	var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = XAverage( Price, FastLength ) ;
var1 = XAverage( Price, MedLength ) ;
var2 = XAverage( Price, SlowLength ) ;

Condition1 = Price < var0 and var0 < var1 and var1 < var2 ;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close < var2) then
	Sell Short ( "MA3CrsSE" ) next bar at market;

Condition1 = Price > var0 and var0 > var1 and var1 > var2 ;

condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close > var2) then
	Buy ( "MA3CrsLE" ) next bar at market ;
Is this what you meant?


Reply With Quote
Thanked by:
  #6 (permalink)
 gfdaniels 
Roswell
 
Experience: Intermediate
Platform: Multicharts
Trading: es tf ym nq
Posts: 10 since Jul 2015
Thanks Given: 0
Thanks Received: 0


Jura View Post
I assumed that your `SlowLength` input is manually set to 50 since I couldn't find an EMA 50. Here I just added the condition that compares the `Close` value against the `var2` variable, which holds the EMA of the `SlowLength` period:

 
Code
Inputs: 
	Price( Close ), FastLength(4 ), MedLength(5 ), SlowLength(8) ;

variables: 
	var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = XAverage( Price, FastLength ) ;
var1 = XAverage( Price, MedLength ) ;
var2 = XAverage( Price, SlowLength ) ;

Condition1 = Price < var0 and var0 < var1 and var1 < var2 ;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close < var2) then
	Sell Short ( "MA3CrsSE" ) next bar at market;

Condition1 = Price > var0 and var0 > var1 and var1 > var2 ;

condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close > var2) then
	Buy ( "MA3CrsLE" ) next bar at market ;
Is this what you meant?

You are right i manually plot the 50 ema on the screen however i would like it to leave those conditions the same accept add that it will not take a short trade it it is above the 50 ema and vice versa, where would i inserst 50 at


Started this thread Reply With Quote
  #7 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 691


gfdaniels View Post
You are right i manually plot the 50 ema on the screen however i would like it to leave those conditions the same accept add that it will not take a short trade it it is above the 50 ema and vice versa, where would i inserst 50 at

Hm, I believe I already added that to the code (see my previous post + motivation).

Did I misunderstand you or doesn't it work for you?


Reply With Quote
  #8 (permalink)
 gfdaniels 
Roswell
 
Experience: Intermediate
Platform: Multicharts
Trading: es tf ym nq
Posts: 10 since Jul 2015
Thanks Given: 0
Thanks Received: 0


Jura View Post
Hm, I believe I already added that to the code (see my previous post + motivation).

Did I misunderstand you or doesn't it work for you?

It did not work, i used it and it did not make a difference, so i dont know if i explained myself. I need the three ema that i have to only fire a signal if it is above or below the 50 ema, so i would assume that i have to add that rule somehow to the code that i have, can you do that for me PLEASE. I really appreciate what you done for me so far.


Started this thread Reply With Quote
  #9 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 691


gfdaniels View Post
You are right i manually plot the 50 ema on the screen however i would like it to leave those conditions the same accept add that it will not take a short trade it it is above the 50 ema and vice versa, where would i inserst 50 at


gfdaniels View Post
It did not work, i used it and it did not make a difference, so i dont know if i explained myself. I need the three ema that i have to only fire a signal if it is above or below the 50 ema, so i would assume that i have to add that rule somehow to the code that i have

Ah I see, I misunderstood you; I thought you configured the signal to an EMA 50 but now I understand that you plotted the EMA50 on the chart (so an indicator).

I've updated your code to include a 50-period EMA now. The input for it is named `SlowerLength`. Try to see if this works for you:

 
Code
Inputs: 
	Price(Close), 
	FastLength(4), 
	MedLength(5), 
	SlowLength(8),
	SlowerLength(50);

Variables:
	emaQuick(0), emaMed(0), emaSlow(0), emaSlower(0);

emaQuick = XAverage(Price, FastLength);
emaMed = XAverage(Price, MedLength);
emaSlow = XAverage(Price, SlowLength);
emaSlower = XAverage(Price, SlowerLength);

Condition1 = Price < emaQuick and emaQuick < emaMed and emaMed < emaSlow;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close < emaSlower) then
	Sell Short ( "MA3CrsSE" ) next bar at market;

Condition1 = Price > emaQuick and emaQuick > emaMed and emaMed > emaSlow;

condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close > emaSlower) then
	Buy ( "MA3CrsLE" ) next bar at market ;


Reply With Quote
  #10 (permalink)
 gfdaniels 
Roswell
 
Experience: Intermediate
Platform: Multicharts
Trading: es tf ym nq
Posts: 10 since Jul 2015
Thanks Given: 0
Thanks Received: 0



Jura View Post
Ah I see, I misunderstood you; I thought you configured the signal to an EMA 50 but now I understand that you plotted the EMA50 on the chart (so an indicator).

I've updated your code to include a 50-period EMA now. The input for it is named `SlowerLength`. Try to see if this works for you:

 
Code
Inputs: 
	Price(Close), 
	FastLength(4), 
	MedLength(5), 
	SlowLength(8),
	SlowerLength(50);

Variables:
	emaQuick(0), emaMed(0), emaSlow(0), emaSlower(0);

emaQuick = XAverage(Price, FastLength);
emaMed = XAverage(Price, MedLength);
emaSlow = XAverage(Price, SlowLength);
emaSlower = XAverage(Price, SlowerLength);

Condition1 = Price < emaQuick and emaQuick < emaMed and emaMed < emaSlow;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close < emaSlower) then
	Sell Short ( "MA3CrsSE" ) next bar at market;

Condition1 = Price > emaQuick and emaQuick > emaMed and emaMed > emaSlow;

condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;

if (condition2 and Close > emaSlower) then
	Buy ( "MA3CrsLE" ) next bar at market ;

YOU ARE THE MAN, GOD BLESS YOU, IT WORKS.


Started this thread Reply With Quote




Last Updated on August 14, 2015


© 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