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:	53
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:	43
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:	44
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 AlessioCianini12, Today, 01:38 AM
                  0 responses
                  27 views
                  0 likes
                  Last Post AlessioCianini12  
                  Started by nandhumca, Yesterday, 11:54 PM
                  0 responses
                  29 views
                  0 likes
                  Last Post nandhumca  
                  Started by nandhumca, Yesterday, 11:51 PM
                  0 responses
                  28 views
                  0 likes
                  Last Post nandhumca  
                  Started by ezrollin, Yesterday, 11:48 PM
                  2 responses
                  29 views
                  0 likes
                  Last Post ezrollin  
                  Started by jjanguda, Yesterday, 10:15 PM
                  1 response
                  28 views
                  0 likes
                  Last Post NinjaTrader_ChrisSch  
                  Working...
                  X