Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Attempting To Convert This

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Attempting To Convert This

    Hello,

    Any help is appreciated.

    I am getting the following errors when I attempt to compile a NT7 indicator in NT8.

    ERROR #1
    Line 66 - Plots[0].Pen.DashStyle = DashStyleHelper.Dot;
    Line 68 - Plots[1].Pen.DashStyle = DashStyleHelper.Dot;
    Line 110 - Plots[0].Pen.DashStyle = DashStyleHelper.Dot;
    Line 111 - Plots[1].Pen.DashStyle = DashStyleHelper.Dot;

    ERROR - Cannot implictly convert type 'NinjaTrader.Gui.DashStyleHelper' to 'System.Windows.Media.DashStyle'

    ERROR #2
    Line 112 - Plots[0].Pen.Color = pColorPS;
    Line 113 - Plots[1].Pen.Color = pColorPL;

    ERROR - 'System.Windows.Media.Pen' does not contain a definition for 'Color' and no extension method 'Color' accepting a first argument of type 'System.Windows.Media.Pen' could be found (are you missing a using directive or an assembly reference?)

    ERROR #3
    Line 463 - double a = 1 - ( 0.299 * bg.R + 0.587 * bg.G + 0.114 * bg.B)/255;

    ERROR - 'System.Windows.Media.Brush' does not contain a definition for 'R' 'G' 'B' and no extension method 'R' 'G' 'B' accepting a first argument of type 'System.Windows.Media.Brush' could be found (are you missing a using directive or an assembly reference?)

    ERROR #4
    Line 470 - return Color.FromRgb(d, d, d);

    ERROR - The best overloaded method match for 'System.Windows.Media.Color.FromRgb(byte, byte, byte)' has some invalid arguments

    Argument 1 (first d on line 470) cannot convert from 'int' to 'byte'.
    Argument 2 (second d on line 470) cannot convert from 'int' to 'byte'
    Argument 3 (third d on line 470) cannot convert from 'int' to 'byte'.


    ERROR #5
    Line 492 - string folder = NinjaTrader.Cbi.Core.InstallDir+@"\sounds";

    ERROR - The type or namespace name 'Core' does not exist in the namespace 'NinjaTrader.Cbi' (are you missing an assembly reference?)

    #2
    Hello CTDavies,

    Thanks for your post.

    There are a few key items to look for when converting your scripts from NinjaTrader 7 format to NinjaTrader 8, and we keep a Code Breaking Changes table updated in the NinjaTrader 8 Help Guide to assist in identifying changes or new implementations of familiar methods and properties from NinjaTrader 7: http://ninjatrader.com/support/helpG...ng_changes.htm

    Some notable items to consider when converting your code will be the following:

    Initialization has changed significantly. Initialize() has been replaced with OnStateChange(), which can be used to filter out different stages of the entire life cycle of a script (SetDefaults, Configure, Historical, Realtime, Terminated, etc.) OnStateChange() is fully covered in the Help Guide.

    The names of many methods and properties have changed slightly, so you will need to refactor these in your code. The Code Breaking Changes table can make this task much easier, and there is also an alphabetical reference in the Help Guide that can help to find new method/property names: http://ninjatrader.com/support/helpG..._reference.htm

    In numerous instances, you now have direct access to objects, where in NinjaTrader 7 you had to work with interfaces. For example, rather than the IOrder interface, you now have direct access to an Order object and its related fields. This will require a change in the way items like this are handled in your code.

    As always, we are more than happy to help out with tips and advice in this area, although we do not offer full script conversion services.

    For error #1, try: Plots[0].DashStyleHelper = DashStyleHelper.Dot;

    For error #2, NT8 uses brushes so an example would be: Plots[0].Brush = Brushes.Red; If you have a brush variable previously defined then you can use for example: Plots[0].Brush = myBrushvar;

    For errors #3 & #4, you may want to review the code of this indicator in the file sharing section: https://ninjatrader.com/support/foru...=7&linkid=1057

    For error #5, NT will default to its install sounds folders so @"Alert1.wav" would point to the sounds folder within the (program files x86) /NinjaTrader8/sounds/
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      For errors #3 & #4, you may want to review the code of this indicator in the file sharing section: https://ninjatrader.com/support/foru...=7&linkid=1057
      Thank you for your response. I have managed to solve errors 1, 2 and 5.

      I have downloaded the script for the RMMA and I can see that it deals with colour differently. However I wouldn't know how to modify my script properly based on it. But I know you don't offer to convert scripts.

      Is anyone willing to look at my script and modify the 2 lines I have errors on?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      179 views
      0 likes
      Last Post jeronymite  
      Started by ghoul, Today, 06:02 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X