Jump to content
Medved Trader Forums

2 decimals instead of 4 and percentage

Recommended Posts

Hi guys,  

Can you help me with the following...
I want to take the 13ema and the 34ema and strip the last 2 digits of the 4 digit decimal value.  I want to be able to search for 2 averages that sit ontop of each other. Its hard to get a match with 4 decimals:) 

On another scan I would like to see a % difference between 13ema and 89ema. 
I would also like to have an option to set an alert on the % diff.

I spent sometime last night reading every post on paintbar looking for examples. I'm not much of a programmer but can tinker with examples to make things work. Thanks for the help.

Link to comment
Share on other sites

Thanks LW.
Im not sure how to make it work. I'm going to spend some time over there to try and learn some basics. I used to play in metastock- they had a primer manual along with a huge collection of user contributed code. There was enough stuff available for me to hack stuff together.  Last time I played with stuff was a decade ago.  BTW thanks for your dragonfly code :) I came across that last night.

I came across this  SetScanResult(Sum(3, Close - Open).ToString("#,###.00##")); from one of the posts here, not sure if I can use the #,###.00 to strip away what I don't want.  I think it was "prec" in metastock that did what Im looking to do.   


Link to comment
Share on other sites

If you're comparing two floating point values for equality, you definitely shouldn't just == them. You can do Math.Abs(A-B)<0.01  if you want to limit it that way. Easier than rounding them up and would take care of the case where one rounds up and the other rounds down.

And yes you can do ONE plot per paintbar, for anything you want. That's the SetYValue function (in general, this page:https://www.medvedtrader.com/trader/WebHelp/advanced_-_all_available_funct.htm will probably be very helpful).

So if the 50SMA is called SMA50 - you can just do these two lines:

SetColor("% diff",Color.Lime);


You'd need to place this paintbar on the extra chart - either above or below the main one. And probably set the shape for the paintbar to size 1 so that the shapes do not obscure the line.


  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...