NexusFi: Find Your Edge


Home Menu

 





MULTICHART CODING


Discussion in MultiCharts

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




 
Search this Thread

MULTICHART CODING

  #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?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Tao te Trade: way of the WLD
24 thanks
Spoo-nalysis ES e-mini futures S&P 500
21 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


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: 690


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: 690


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: 690


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


© 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