Salvatore Posted December 8, 2016 Report Share Posted December 8, 2016 hello, i need help with this from QT to Medved. i am doing everything manually since there is no import for the paintbars, I have this on the QT paintbar and i need converted to Medved. Two rules: if (ABS((Bar Open - Bar Close) / (Bar High - Bar Low)) <= 0.35) and (Bar Low < EMA(30)) set color to White if (ABS((Bar Open - Bar Close) / (Bar High - Bar Low)) <= 0.2) and (Bar Low < EMA(30)) set color to White I have this for Medved: Ema_Line parameter 30 Any help with this will be appreciated. Thanks Sal Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted December 9, 2016 Report Share Posted December 9, 2016 Assuming you have that EMA_Line defined, here is what the code (in Advanced Mode) would look like: public void MainCalculation() { if ((Math.Abs(Open - Close) / (High - Low)) <= 0.2D && Low < EMA_Line) { SetColor("Main", Color.White); } else if ((Math.Abs(Open - Close) / (High - Low)) <= 0.35D && Low < EMA_Line) { SetColor("Main", Color.White); } } NOTE: you are setting it to White in both situations - I assume you want to set it to different colors. You can change them as needed. Also, right now in the example I defined one named color ("Main"), so when you add the paintbar to the chart and look at the parameters, there will be a color box defaulted to White, but which you can change. That way you do not have to hardcode the color in the Paintbar definition. If you use 2 different names in the 2 IF statements above, then there will be 2 defined colors and you would be able to set them in the chart indicator parameters independently. 1 Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted December 9, 2016 Report Share Posted December 9, 2016 One thing I would add is adding the if (High==Low) check - since otherwise you could be dividing by 0. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.