NexusFi: Find Your Edge


Home Menu

 





Trading using multiple time frames in Multicharts


Discussion in MultiCharts

Updated
    1. trending_up 7,365 views
    2. thumb_up 7 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 1 attachments




 
Search this Thread

Trading using multiple time frames in Multicharts

  #1 (permalink)
bondstrader
Dubai, UAE
 
Posts: 10 since Sep 2014
Thanks Given: 2
Thanks Received: 1

Hi everyone.
Ive recently gotten into using multicharts, and I have one query, which may or may not have already been asked on this forum. Ive searched and found similar stuff, but nothing that answered my query.

What I want to do is chart an instrument using 2 time frames, but trade on a 3rd time frame. i-e, track the movement of an instrument simultaneously on the daily and weekly timeframes, and when a trigger is hit on these timeframes, trade on the 10 minute bar.
How can i do this?
 
Code
//data1 is the 10 min timeframe
varSMA1 = Average(Close,20) of data2;    //data2 being the daily time frame
varSMA2 = Average(Close,20) of data3;   //data3 being the weekly time frame

if Price > varSMA1 and Price > varSMA2 then begin

Buy 1 Contract Next data1 Bar at Market  //??

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
What broker to use for trading palladium futures
Commodities
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Hi bondstrader,

you can only execute trades on Data1 with Powerlanguage code. So you don't have to specify the datastream in your order command.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
bondstrader
Dubai, UAE
 
Posts: 10 since Sep 2014
Thanks Given: 2
Thanks Received: 1


Thanks ABCTG. Makes sense.

On a related note, when I plot the above time frames on a chart window, what does the 'Base Study On' part mean? If Im trading on the 10 min bar while using the information from the daily and weekly bars, which time frame should i 'base study on'?

Reply With Quote
Thanked by:
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

bondstrader,

you are welcome. "Base study on" only comes into play with indicators and I would suggest to base it on the datastream that gives the most updates and adapt the code accordingly. This would also be my suggestion for a signal - use the fastest datastream as data1 and adapt the signal accordingly. If your trade datastream is not the fastest stream on the chart it's usually less hassle to use an additional faster datastream of the same symbol for trade execution and use the "original" trade datastream for generating the signals.
Of course you can make it work when data1 is not the fastest chart, but it's usually harder and more work than doing what I wrote above.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
bondstrader
Dubai, UAE
 
Posts: 10 since Sep 2014
Thanks Given: 2
Thanks Received: 1

Thanks a lot for your help so far ABCTG......
Im having quite a few issues with multi time frames, so your help is a god-send.
Below is a basic version of the code Im trying to implement. data1 is the daily chart, and data2 is weekly. The signal is supposed to trigger a trade whenever the high bars of the 2 charts are crossed.
However, it doesnt always happen that way. I cant attach a screenshot as I have less than 5 posts..but there are many trades that triggered even though both the high bars were not breached.
Plus, Ive added a condition for max position to be 10, but that doesnt seem to matter either, as the strategy runs away with trades Any ideas?
 
Code
INPUT : 
PRICE(Close), LENGTH(3), DISPLACE(-1), MaxPos(10), begin_time(0900), end_time(1500), 
fivetoclose(1255);

Variables:
varDA (0),
varDB (0),
varDC (0),
varWA (0),
varWB (0),
varWC (0);
	
varDA = Average(High, LENGTH) of data1;
varDB = Average(PRICE, LENGTH) of data1;
varDC = Average(Low, LENGTH) of data1;	
varWA = Average(High, LENGTH) of data2;     
varWB = Average(PRICE, LENGTH) of data2;   
varWC = Average(Low, LENGTH) of data2;

//Initiating new position

IF DISPLACE < 0 THEN BEGIN
[IntrabarOrderGeneration = True];
If marketposition < MaxPos then begin

condition1 = CurrentBid >= varDA; 
condition2 = CurrentBid >= varWA;
 
if condition1 and condition2 then begin  
	Buy ("Enter Long-L1") 1 Contract Next Bar at CurrentAsk Limit;
end;
end;
end;

Attached Thumbnails
Click image for larger version

Name:	screenshot.GIF
Views:	231
Size:	19.0 KB
ID:	158476  
Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

bondstrader,

marketposition can only have one of three values - 0 if you are flat, +1 if you are long and -1 if you are short.
Therefore your condition is always true and the signal keeps adding trades.
You are looking for something like "CurrentEntries".

From looking at your code it's not exactly clear what you are trying to get at - you are using intrabar order generation, but none of the variables is intrabarpersist (which might not be needed, but I thought I'd point it out). Besides that you should tie variables to data2 specifically on declaration in my opinion.

The next thing would be for you to add print statements to your code to debug what exactly the values are at the point of an entry. This will help you figuring out what is happening in your code and what is different than what you want it to do.

Regards,
ABCTG

Follow me on Twitter Reply With Quote




Last Updated on September 26, 2014


© 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