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

printing text strings and variables

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

    printing text strings and variables

    Click image for larger version

Name:	aaaaaaaaaaaaaa.png
Views:	347
Size:	58.6 KB
ID:	1176344

    Sorry this is so basic.
    Why cant I drag this print statement and move it to where I want?
    Or why isnt there a button to move it up/down?
    I would literally have to go and erase all the work to get stuff where I want it.
    I dont know why this isnt already there.

    Anyways. Trying to debug why my bot keeps crashing when it sells.
    I'm just trying to add strings to my text variable statements
    I'm trying to do stuff like:
    Print ("Long: " + Convert.ToString(MarketPosition.Long));
    or
    Print ("Long: " && Convert.ToString(MarketPosition.Long));
    or
    Print ("Long: " , + , Convert.ToString(MarketPosition.Long));
    I'm obviously not doing it correctly.
    What is the right way? Thanks!

    #2
    Hello ezrollin,

    Unfortunately those are not features of the builder currently, You would need to remove and re add the actions to change the order.

    For the print I would suggest to first identify which line specifically you are having a problem with.

    If you are observing something unexpected we would need to know what you had observed and what the use case was. For example you mentioned crashing, if you are seeing a literal crash where the platform exits it would be best to attach a sample strategy that shows that issue along with directions on how to cause the issue and mention it exits. If you instead used crash interchangeably and the strategy is just disabling or having a problem we would need more specific details on what happened and which specific print/action was the problem.

    A note on the prints would be that you are trying to print the enum and not the actual position. To print the position you would need to select the Strategy - Current market position. That would end up looking like this:
    Print(Convert.ToString(Position.MarketPosition));


    Please let me know if I may be of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      No. The executable is not crashing. Just my strategy is being forced into disabling itself and I dont know why.
      I'm just trying to figure out whats going on.
      I'm trying to add a text string to my print command and have a variable at the same time.
      Should be very easy but I cant figure it out.
      Is it not possible? thanks

      maybe:
      Print ("Long: " + (Convert.ToString(MarketPosition.Long)));

      Comment


        #4
        Wish you could edit the code in the builder without unlocking the code.

        Comment


          #5
          Click image for larger version

Name:	222222222222222.png
Views:	321
Size:	57.8 KB
ID:	1176353
          There, I did it the long, uncondensed, unpretty way

          Comment


            #6
            Hello ezrollin,

            No. The executable is not crashing. Just my strategy is being forced into disabling itself and I dont know why.
            That sounds like an error, you can review the control center log tab or NinjaScript output window to see why.

            The last post you provided where everything is working is no longer using the position enum so that may be why. Again if you are trying to print the position as Long or Short you would have to use Strategy -> Current Market Position and not one of the specific positions like Long. If you wanted to output the text "Long" or "Short" you can also just add a string with that text like you have.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Click image for larger version

Name:	333333333333.png
Views:	326
Size:	59.9 KB
ID:	1176358

              Yes I didnt realize until later what I put in but I fixed it.
              Anyways, I still dont know the answer to my question.

              How to add text to my print command followed by an integer, followed by text followed by a variable, etc etc etc

              I found this:
              Print("The current bar range is greater than the 3 bar average range of " + AverageRange().ToString());
              But when I try to put in a statement like that it doesnt include my text i write "The current bar range is greater than the 3 bar average......." would be left out/erased

              Also if I hit backspace one time, it erases all of the work. (I dont like that) thanks

              Comment


                #8
                Hello ezrollin,

                In the print action you can add multiple strings using the string builder, that would create strings like what you pasted where a variable is used.

                After adding Print, in the dialog that opens click the Add button to add more strings. Each new line is a part of the string which is added together for the final string.


                Please let me know if I may be of further assistance.


                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Sorry I forgot there was an ADD button there.
                  That was my problem!
                  see I told you my question was really really basic thanks!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Barry Milan, Today, 10:35 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by WeyldFalcon, 12-10-2020, 06:48 PM
                  14 responses
                  1,427 views
                  0 likes
                  Last Post Handclap0241  
                  Started by DJ888, Yesterday, 06:09 PM
                  2 responses
                  9 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  40 views
                  0 likes
                  Last Post jeronymite  
                  Started by bill2023, Today, 08:51 AM
                  2 responses
                  16 views
                  0 likes
                  Last Post bill2023  
                  Working...
                  X