NexusFi: Find Your Edge


Home Menu

 





Easylanguage with multiple timeframe indicators


Discussion in EasyLanguage Programming

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




 
Search this Thread

Easylanguage with multiple timeframe indicators

  #1 (permalink)
JayWhite
Houston, Texas
 
Posts: 4 since May 2023
Thanks Given: 0
Thanks Received: 0

Hi, can someone please help me on the code below? I am testing a strategy using MACD indicators based 5 min chart (data1) and 30 min chart (data2). For the statements below, I am sure the first one will calculate MACD based on 12 and 26 bars of 30 min. However, Easylanguge does not allow me to specify something like "MyMACD2 of data2". If I keep the second statement as below, the length of 9 implies 9 of 30min bar or 9 of 5min bar? If it implies 9 of 5min bar, is it ok to change it to 54? Any other workaround? Thank you!

MyMACD2 = MACD( Close of data2, 12, 26);
MACDAvg2 = XAverage( MyMACD2, 9);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
use extra computer for optimisation
NinjaTrader
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #2 (permalink)
 
Tripken's Avatar
 Tripken 
Knoxville, TN/USA
Market Wizard
 
Experience: Beginner
Platform: TradeStation
Broker: TradeStation
Trading: ES
Frequency: Several times daily
Duration: Minutes
Posts: 624 since Feb 2010
Thanks Given: 1,583
Thanks Received: 1,368

Hi Jay,

I'm not a EL expert but I believe that can be done as long as you're using time based charts. I use tick charts so no way to use multiple TF's.

I know this isn't a lot of help and hope it's OK with FutureIO. Since you're looking for something Tradestation specific I would ask this on the TS forum, if you haven't already. They have a lot of knowledgeable folks on there and support staff for programming Q's.

Hope it helps and good luck.

https://community.tradestation.com/Discussions/RecentPost.aspx

Reply With Quote
  #3 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 34 since Mar 2012
Thanks Given: 1
Thanks Received: 21


You can tie your variables to either Data1 or Data2 in the Declarative Statements. In the code below, I have tied both MyMACD2 and MACDAvg2 to Data2. Also, I have specified in the code that the functions
MACD and XAverage are to operate on Data2. However, even though the calculations are performed on Data2, the "next bar" in the buy and sell entry/exit statements refer to the next bar of Data1 as trades are always executed on Data1.

View the EasyLanguage Print Log to see the Printed messages. New lines will be added to the messages if a Data2 bar has closed and either a cross above or a cross below has happened.

 
Code
Vars:
	MyMACD2(0,Data2),
	MACDAvg2(0,Data2);


MyMACD2 = MACD( Close of data2, 12, 26) of Data2;
MACDAvg2 = XAverage( MyMACD2, 9) of Data2;

If MyMACD2 crosses above MACDAvg2 then buy 1 contract next bar at market;
If MyMACD2 crosses below MACDAvg2 then sell short 1 contract next bar at market;

If BarStatus(2) = 2 then Begin
	If MyMACD2 crosses above MACDAvg2 or MyMACD2 crosses below MACDAvg2 then begin
		Print("Date = ",Date,"   Time = ",Time,"  MyMACD2 = ",MyMACD2:0:3,"   MACDAvg2 = ",MACDAvg2:0:3,"  MyMACD2[1] = ",MyMACD2[1]:0:3,"  MACDAvg2[1] = ",MACDAvg2[1]:0:3);
	end;
End;

Follow me on Twitter Reply With Quote
  #4 (permalink)
JayWhite
Houston, Texas
 
Posts: 4 since May 2023
Thanks Given: 0
Thanks Received: 0

TraderDoc2, Your are very helpful. Thanks a lot!


TraderDoc2 View Post
You can tie your variables to either Data1 or Data2 in the Declarative Statements. In the code below, I have tied both MyMACD2 and MACDAvg2 to Data2. Also, I have specified in the code that the functions
MACD and XAverage are to operate on Data2. However, even though the calculations are performed on Data2, the "next bar" in the buy and sell entry/exit statements refer to the next bar of Data1 as trades are always executed on Data1.

View the EasyLanguage Print Log to see the Printed messages. New lines will be added to the messages if a Data2 bar has closed and either a cross above or a cross below has happened.

 
Code
Vars:
	MyMACD2(0,Data2),
	MACDAvg2(0,Data2);


MyMACD2 = MACD( Close of data2, 12, 26) of Data2;
MACDAvg2 = XAverage( MyMACD2, 9) of Data2;

If MyMACD2 crosses above MACDAvg2 then buy 1 contract next bar at market;
If MyMACD2 crosses below MACDAvg2 then sell short 1 contract next bar at market;

If BarStatus(2) = 2 then Begin
	If MyMACD2 crosses above MACDAvg2 or MyMACD2 crosses below MACDAvg2 then begin
		Print("Date = ",Date,"   Time = ",Time,"  MyMACD2 = ",MyMACD2:0:3,"   MACDAvg2 = ",MACDAvg2:0:3,"  MyMACD2[1] = ",MyMACD2[1]:0:3,"  MACDAvg2[1] = ",MACDAvg2[1]:0:3);
	end;
End;


Reply With Quote




Last Updated on June 11, 2023


© 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