NexusFi: Find Your Edge


Home Menu

 





Plot Value "Data Window" / Programatic discrepancy


Discussion in MultiCharts

Updated
    1. trending_up 3,349 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Plot Value "Data Window" / Programatic discrepancy

  #1 (permalink)
 
WolfieWolf's Avatar
 WolfieWolf 
Charlottetown, Prince Edward Island
 
Experience: Advanced
Platform: Ninja
Broker: Optimus - Rithmic
Trading: GC
Posts: 232 since Jul 2010
Thanks Given: 100
Thanks Received: 272

Hello Everyone,

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.

Thanks

Wolfie (the werewolf) Wolf

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
31 thanks
Just another trading journal: PA, Wyckoff & Trends
20 thanks
My NQ Trading Journal
19 thanks
Tao te Trade: way of the WLD
14 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,439 since Jun 2009
Thanks Given: 33,205
Thanks Received: 101,599


WolfieWolf View Post
Hello Everyone,

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.

Thanks

Wolfie (the werewolf) Wolf

Very interesting, can you post a minimal amount of code to duplicate this behavior? I'd like to check it out.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
WolfieWolf's Avatar
 WolfieWolf 
Charlottetown, Prince Edward Island
 
Experience: Advanced
Platform: Ninja
Broker: Optimus - Rithmic
Trading: GC
Posts: 232 since Jul 2010
Thanks Given: 100
Thanks Received: 272


Hi Big Mike,

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.

MCFX Power Language(Easy Language) Coding Issue - Traders Laboratory Forums

"take values and string them and then print them because of the 2 dec place limit for float in the output bar
just a print tip since your coding problem was solved".

Inputs:
Value((High+Low)/2),

Var:
Float MyBlue (0),
BlueString(" "),
Float MyRoundedBlue(0);

value1=Average(value,16)[2];

plot1(value1,"MyBlue");

If you:
print ("MyBlue ", plot1);

you get a two decimal output which may or may not be the same as what's in the output window. If you do as the poster above suggested:

BlueString = NumToStr(Plot1,4);

and then:
print ("BlueString ", BlueString);

you get a 4 decimal value that, when rounded, will match the value in the output window _every_ time. So I did the following:

MyBLue=StrToNum(BlueString);

MyRoundedBlue=round(MyBlue,2);

then when you print or compare the MyRoundedBlue the value matches the output window. I coded this right in your forum editor so I hope I didn't mess anything up.

At first I thought my "offset" of the average was creating the issue but that wasn't the case at all. I hope this helps someone.

All the best

Wolfie (the werewolf) Wolf

Started this thread Reply With Quote
  #4 (permalink)
 SPMC 
GER
 
Experience: Advanced
Platform: MC
Trading: ES
Posts: 144 since May 2011
Thanks Given: 11
Thanks Received: 213

You can use print ("MyBlue ", plot1:7:X) and replace X with the decimalplaces you want to print/the data window shows.

Reply With Quote
  #5 (permalink)
 
WolfieWolf's Avatar
 WolfieWolf 
Charlottetown, Prince Edward Island
 
Experience: Advanced
Platform: Ninja
Broker: Optimus - Rithmic
Trading: GC
Posts: 232 since Jul 2010
Thanks Given: 100
Thanks Received: 272

SPMC, you rock! I had no idea. What is the source of your information?

Started this thread Reply With Quote
  #6 (permalink)
 
WolfieWolf's Avatar
 WolfieWolf 
Charlottetown, Prince Edward Island
 
Experience: Advanced
Platform: Ninja
Broker: Optimus - Rithmic
Trading: GC
Posts: 232 since Jul 2010
Thanks Given: 100
Thanks Received: 272

Hi SPMC,

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.

Thanks

Wolfie (the werewolf) Wolf

Started this thread Reply With Quote
  #7 (permalink)
 SPMC 
GER
 
Experience: Advanced
Platform: MC
Trading: ES
Posts: 144 since May 2011
Thanks Given: 11
Thanks Received: 213

Wolf,

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)[2]; is i.e. 1.4735665688 the code uses all 10 decimalplaces, regardless what the plot or print statement says, even if the plot says
1.4736.

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)[2] , X ); with X as your
decimals.

Reply With Quote




Last Updated on June 6, 2011


© 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