Does MRO function automatically cut off bars? - futures io
futures io futures trading



Does MRO function automatically cut off bars?


Discussion in TradeStation

Updated by minoschan
    1. trending_up 376 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 4 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Does MRO function automatically cut off bars?

(login for full post details)
  #1 (permalink)
Shenzhen China
 
 
Posts: 3 since Aug 2019
Thanks: 1 given, 0 received

Hey guys, I'm a newbie here, and please forgive me if I'm asking a silly question. And yes I live in China, I'll try my best to describe my problem in Chinglish.

I tried to set up an indicator like errr...price diversion. My code is like this:

Variables:
double DIFF(0), double DEA(0), double MyMACD(0),MACD_GCross(False),
MACD_DCross(False), int BarsUp(0);

DIFF = XAverage(Close, 12) - XAverage(Close, 26);
DEA = XAverage(DIFF, 9);
MyMACD = 20*(DIFF-DEA); //It was multiplied by 20 for convenience only, actually it should be 2hi
Plot1(DIFF, "DIFF", White);
Plot2(DEA, "DEA", Yellow);
Plot3(MyMACD, !("MyMACD")); //Displayed in histogram
if MyMACD > 0 then
SetPlotColor(3, Red)
else if MyMACD < 0 then
SetPlotColor(3, Cyan);

MACD_GCross = DIFF cross over DEA;
MACD_DCross = DIFF cross under DEA;
BarsUp = MRO(MACD_GCross, 200, 1) + 1; //Calculating the bars since the last time DIFF crossed over DEA, in a 200- bar length

...


So here's the problem. It was verified all OK. But when I add it to my bars chart, the first 200 verticle lines plotted(i.e. MyMACD Variable) was automatically removed from the chart. If I remove the "BarsUp = MRO(MACD_GCross, 200, 1) + 1;" sentence, it was plotted right. Anyone have any idea what's wrong with my code? What should I do if I wanna keep all the lines without removing the MRO function, which I think is a very handy function for newbies like me. I Any help is appreciated.

Best Regards

Attached Thumbnails
Click image for larger version

Name:	WX20190830-194407@2x.png
Views:	28
Size:	795.9 KB
ID:	274220  
Reply With Quote

Can you help answer these questions
from other members on futures io?
Chart on TV, what platform is best for swing order entries?
Traders Hideout
Order Data Export Plugin-- Is it possible?
NinjaTrader
converting useful Pine Script into Multicharts code
EasyLanguage Programming
Convert H Data TS to NT
NinjaTrader
Das Trader Pro
Platforms and Indicators
 
 
(login for full post details)
  #2 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,217 since Apr 2013
Thanks: 396 given, 1,451 received

minoschan,

this is likely caused by the maximum number of bars that Tradestation requires for a study.
You can read more about it here:
Maximum Number of Bars Study Will Reference Setting

Regards,

ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #3 (permalink)
Shenzhen China
 
 
Posts: 3 since Aug 2019
Thanks: 1 given, 0 received


Thanks for the quick tip, ABCTG. I was googling how to use the Maxbarback and will try to figure it out by myself.
I'd like to bring forward one more question without adding a new thread. On many occasions, when I try to plot some lines for my variables, TS won't allow me to plot from the first bar(i.e. the first in history of a stock). I tried these code:
"Value1=10.01;
Plot1(Value1, "Value1")
;
And it plotted the value from the SECOND bar, which should be BarNumber 1 I suppose.
I tried "Value 1 = Close;", it also began from the second bar(BarNumber 1). So what's the usual way to reference the REAL first bar, and plot the Values exactly from the beginning?
P.S. Certain functions like MACD also IGNORED the first Bar. The first Bar arguably has no 'previous EMA value', but the code actually presumes the second Bar Price to be the 'previous value' for the third Bar. It used the same method, like many other platforms, except it just IGNORED the first Bar.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,217 since Apr 2013
Thanks: 396 given, 1,451 received

minoschan,

I am not sure you can get around this platform behavior. If starting at the very first bar of a session is important you could load one additional session and start your code logic on the first bar of the second session.

Regards,

ABCTG



minoschan View Post
Thanks for the quick tip, ABCTG. I was googling how to use the Maxbarback and will try to figure it out by myself.
I'd like to bring forward one more question without adding a new thread. On many occasions, when I try to plot some lines for my variables, TS won't allow me to plot from the first bar(i.e. the first in history of a stock). I tried these code:
"Value1=10.01;
Plot1(Value1, "Value1")
;
And it plotted the value from the SECOND bar, which should be BarNumber 1 I suppose.
I tried "Value 1 = Close;", it also began from the second bar(BarNumber 1). So what's the usual way to reference the REAL first bar, and plot the Values exactly from the beginning?
P.S. Certain functions like MACD also IGNORED the first Bar. The first Bar arguably has no 'previous EMA value', but the code actually presumes the second Bar Price to be the 'previous value' for the third Bar. It used the same method, like many other platforms, except it just IGNORED the first Bar.


Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #5 (permalink)
Shenzhen China
 
 
Posts: 3 since Aug 2019
Thanks: 1 given, 0 received

Tried to modify the XAverage function. And it works better now. Thought of a way to work around the manner of TS, which means I'll have to write some more code myself. Thanks ABCTG for your help and patience!

Regards,

Reply With Quote


futures io Trading Community Platforms and Indicators TradeStation > Does MRO function automatically cut off bars?


September 4, 2019


Upcoming Webinars and Events
 

Bookmap

Nov TBD
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts