Plot Value "Data Window" / Programatic discrepancy
I'm hoping someone can answer this for me. I'm programming a very simple indicator. It plots two simple moving averages over price. When I hover my mouse over the bar where the moving averages cross I can see the values in the Data Window and / or the "hint" window. I want to write some code to take action when some conditions are met using the values of the two moving average plots. The issue is that the value of the plots is not _always_ the same programatically as it is on the screen. For examle if I print (plot1); and compare the values will match for a series of bars but occasionally they are different by a tick one way or ther other.... For my strategy a tick actually makes a difference and I want to know why there is a discrepancy. A values a value and I know which value I want. I've tried using the bar status to get the value on the first tick but that doesn't seem to work on historical data (and I want to backtest). I also tried using the last tick, but thats not the value I want either. I'm using MC 7 beta 4 ( which rocks by the way)... Any ideas? I would really appreciate any advice.
Very interesting, can you post a minimal amount of code to duplicate this behavior? I'd like to check it out.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
It's a pleasure to finally meet you; I've been lurking. Hopefully I can start contributing now. After I posted, and you responded, I spent a considerable amount of time on this on Sunday. (I know, I know, get a like Wolfie Wolf).
Without getting into too many specifics of my code, which I'm not comfortable posting in it's entirety, here is a high level explanation of the issue and the resolution. Interestingly, "resolution" is an important factor here because the problem is a rounding issue which only appears when the resolution is set to a specific time frame and the moving averages are set to specific values. (I've changed the values in the sample below). I tried to reproduce this using alternate settings, so I could provide a detailed example, but I wasn't successful in the time I had. I don't have time to hammer on this right now. If you're really keen Mike I could PM you on this. It's important to note that this issue appeared while evaluating my code against CL N1, which is what I thought you would find most interesting.
I found one comment in the following thread that tweaked me to the idea that the number of decimal places and therefore rounding of values stored in variables may be different from the values being plotted n the chart and displayed in the data window. Better documentation for MC would be beneficial, most of what I have been learning from is Tradestation related.
I've had a chance to play around with your suggestion. Your tip works great for formatting the output to the output bar, thanks. It doesn't, however, do anything for the values in the variables. When I compare value1 and value2 with a logical expression like "if value1 = value2" it compares just the first two decimals, not all 4. How can I let MC know when I call a variable that contains 4 decimal places that I want to use all 4 decimal places without first converting it to a string and then converting it back as I demonstrated above? I don't actually want to use all 4 decimals but I do want to round the second decimal using the third decimal place.
at the moment i dont really know exactly what you want to do. The inline codes always compares all available decimalplaces of the variables, that means if
value1=Average(value,16); is i.e. 1.4735665688 the code uses all 10 decimalplaces, regardless what the plot or print statement says, even if the plot says
If you want to use less decimalplaces you need to round the variable and not the print ot plot statement with value1 = round (Average(value,16) , X ); with X as your