NexusFi: Find Your Edge


Home Menu

 





Moving Average of Data2


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 2 posts (2 thanks)
    2. looks_two kristian with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Jura with 1 posts (1 thanks)
    1. trending_up 2,585 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Moving Average of Data2

  #1 (permalink)
kristian
Zurich
 
Posts: 8 since Aug 2015
Thanks Given: 4
Thanks Received: 3

I have a strategy on Data1 (15M chart) with a simple moving average filter using Data2 (daily chart). Long trades are only taken when above the 100-day MA and short trades only when it is below.

The strange thing is that I get different (better) results when using the close of data2 instead of the normal close (of data1).

Below is some code to clarify what I mean:

 
Code
	
Condition7 = Close > Value2; // Profit Factor 1.53
 
Code
	
Condition7 = Close of Data2 > Value2; // Profit Factor 2
*Value2 being the value of the moving average

Shouldn't the results be the same? Is the 2nd code looking into the future?

Thanks for your help!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
29 thanks
Tao te Trade: way of the WLD
24 thanks
Diary of a simple price action trader
21 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
10 thanks
  #3 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



kristian View Post
I have a strategy on Data1 (15M chart) with a simple moving average filter using Data2 (daily chart). Long trades are only taken when above the 100-day MA and short trades only when it is below.

The strange thing is that I get different (better) results when using the close of data2 instead of the normal close (of data1).

Below is some code to clarify what I mean:

 
Code
	
Condition7 = Close > Value2; // Profit Factor 1.53
 
Code
	
Condition7 = Close of Data2 > Value2; // Profit Factor 2
*Value2 being the value of the moving average

Shouldn't the results be the same? Is the 2nd code looking into the future?

I don't think I follow you: if Data1 is a 15-minute chart and Data2 is a daily chart, isn't it to be expected that `Close` (of data 1) gives a different value than `Close of Data2`?

Only once per day is `Close` the same as `Close of data2`, and that's when the 15-minute bar is the last bar of the day. But for all other bars I'd say it's normal to have a difference between them. Or do you use intra-bar order generation and the Bar Magnifier feature?

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

Close Data2 is likely the last closed bar on your chart (yesterday) where Close is the last closed bar on the 15 minute chart. This is assuming the absence of intrabar order generation.
Therefore the results can and will be different, like @Jura pointed out, too. One good way of checking things and seeing the difference can be using the Print command and the output window to show the actual values for Close, Close Data2 and Value2.
On a side note I'd suggest to start using meaningful variable names as this can help you in the future. With variables you declare you can actually tie them to certain datastreams, which you can't do with Value2.

Regards,
ABCTG



kristian View Post
I have a strategy on Data1 (15M chart) with a simple moving average filter using Data2 (daily chart). Long trades are only taken when above the 100-day MA and short trades only when it is below.

The strange thing is that I get different (better) results when using the close of data2 instead of the normal close (of data1).

Below is some code to clarify what I mean:

 
Code
	
Condition7 = Close > Value2; // Profit Factor 1.53
 
Code
	
Condition7 = Close of Data2 > Value2; // Profit Factor 2
*Value2 being the value of the moving average

Shouldn't the results be the same? Is the 2nd code looking into the future?

Thanks for your help!


Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
kristian
Zurich
 
Posts: 8 since Aug 2015
Thanks Given: 4
Thanks Received: 3

Thanks for your answers @Jura and @ABCTG !

I thought that the Close of the daily bar would be the same as the 15M bar because (intrabar og turned off) they move in sync. I assumed that the script gets calculated on every tick and that Close referred to the current close of the bar (even if it's not closed yet).

So if I understand you guys right this is only true with intra bar order generation turned on? And otherwise the script is only calculated on every new bar hence the Close values will be different?

@ABCTG Thanks for the print suggestion, I should have tried that before! Also would you mind clarifying what you mean by "you can actually tie them to certain datastreams"

Thanks a lot for your help!

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

kristian,

you are welcome. You can find more information about variables and how to tie them to datastreams here in the [AUTOLINK]Multicharts[/AUTOLINK] wiki.

When you tie a variable to a datastream you specify when it will be updated i.e. in line with this datastream. If you don't do that, the variable will updated whenever the Data1 variables are update.

Regards,

ABCTG


kristian View Post
Thanks for your answers @Jura and @ABCTG !

I thought that the Close of the daily bar would be the same as the 15M bar because (intrabar og turned off) they move in sync. I assumed that the script gets calculated on every tick and that Close referred to the current close of the bar (even if it's not closed yet).

So if I understand you guys right this is only true with intra bar order generation turned on? And otherwise the script is only calculated on every new bar hence the Close values will be different?

@ABCTG Thanks for the print suggestion, I should have tried that before! Also would you mind clarifying what you mean by "you can actually tie them to certain datastreams"

Thanks a lot for your help!


Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on November 11, 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