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



Does MRO function automatically cut off bars?


Discussion in TradeStation

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,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)
minoschan
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:	44
Size:	795.9 KB
ID:	274220  
Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(133 thanks from 19 posts)
looks_twoSalao's Journalby Salao
(45 thanks from 9 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(34 thanks from 15 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(15 thanks from 12 posts)
looks_5Maybe a little bit different journalby Malykubo
(14 thanks from 13 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Would You Sell Your System?
79 thanks
Big Mike in Ecuador
75 thanks
The Crude Dude Oil Trading System
61 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
25 thanks
futures io site changelog and issues/problem reporting
22 thanks
 
(login for full post details)
  #2 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 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 Reply With Quote
 
(login for full post details)
  #3 (permalink)
minoschan
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)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 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 Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #5 (permalink)
minoschan
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?


Last Updated on September 4, 2019


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 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