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

Prints on separate lines

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

    Prints on separate lines

    Hello

    I am trying to get my prints on separate lines with one Print, so I can see them better without using Print(string.Format(...)) for every line, but I'm not sure how to do it.

    I thought " \n " would do the trick, but it doesn't...

    #2
    Hello itrader46,

    Use "\r\n" in the string for a return carriage and a new line.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Great, thank you.

      One more thing, though: I can only write the statement between " " on one long line (as in the first code window), but when I am breaking it, the part on the second line changes from blue to white and at the end of the first blue line({4}), it's asking for another ' " ', then for two ' ) ', then for ' ; ' , then for a statement...

      Code:
      Print (string.Format("Bar[2] 5 min {0}  \r\nDMI Swing High[0] {1 :F4} | DMI Swing High Bar[0] {2}  \r\nDMI Swing Low[0] {3 :F4} | DMI Swing Low Bar[0] {4} \r\nPrice Swing High[0] {5} | Price Swing High Bar[0] {6} \r\nPrice Swing Low[0] {7} | Price Swing Low Bar[0] {8}  \r\nLast Price Swing High {9} | Last Price Swing High Bar {10} \r\nLast Price Swing Low {11} | Last Price Swing Low Bar {12} \r\nLast DMI Swing High {13 :F4} | Last DMI Swing High Bar {14}  \r\nLast DMI Swing Low {15 :F4} | Last DMI Swing Low Bar {16} \r\n#", 
                                          CurrentBar - 2, HSwDMI[0], HSwDMIbar, LSwDMI[0], LSwDMIbar, HSwPrice[0], HSwPriceBar, LSwPrice[0], LSwPriceBar, 
                                          LastHSwPrice[0], LastHSwPriceBar, LastLSwPrice[0], LastLSwPriceBar, LastHSwDMI[0], LastHSwDMIbar, LastLSwDMI[0], LastLSwDMIbar));
      Code:
      Print (string.Format("Bar[2] 5 min {0}  \r\nDMI Swing High[0] {1 :F4} | DMI Swing High Bar[0] {2}  \r\nDMI Swing Low[0] {3 :F4} | DMI Swing Low Bar[0] {4} 
                                          \r\nPrice Swing High[0] {5} | Price Swing High Bar[0] {6} \r\nPrice Swing Low[0] {7} | Price Swing Low Bar[0] {8}  \r\nLast Price Swing High {9} | Last Price Swing High Bar {10} \r\nLast Price Swing Low {11} | Last Price Swing Low Bar {12} \r\nLast DMI Swing High {13 :F4} | Last DMI Swing High Bar {14}  \r\nLast DMI Swing Low {15 :F4} | Last DMI Swing Low Bar {16} \r\n#", 
                                          CurrentBar - 2, HSwDMI[0], HSwDMIbar, LSwDMI[0], LSwDMIbar, HSwPrice[0], HSwPriceBar, LSwPrice[0], LSwPriceBar, 
                                          LastHSwPrice[0], LastHSwPriceBar, LastLSwPrice[0], LastLSwPriceBar, LastHSwDMI[0], LastHSwDMIbar, LastLSwDMI[0], LastLSwDMIbar));

      Comment


        #4
        Hello itrader46,

        Thank you for your reply.

        You're breaking the string into two lines in the second version. To avoid this, put an @ before the string, like this:

        Code:
        Print (string.Format(@"Bar[2] 5 min {0}  
                        DMI Swing High[0] {1 :F4} | DMI Swing High Bar[0] {2}  
                        DMI Swing Low[0] {3 :F4} | DMI Swing Low Bar[0] {4}
                        Price Swing High[0] {5} | Price Swing High Bar[0] {6} 
                        Price Swing Low[0] {7} | Price Swing Low Bar[0] {8}  
                        Last Price Swing High {9} | Last Price Swing High Bar {10} 
                        Last Price Swing Low {11} | Last Price Swing Low Bar {12} 
                        Last DMI Swing High {13 :F4} | Last DMI Swing High Bar {14}  
                        Last DMI Swing Low {15 :F4} | Last DMI Swing Low Bar {16}", 
                        CurrentBar - 2, HSwDMI[0], HSwDMIbar, LSwDMI[0], LSwDMIbar, HSwPrice[0], HSwPriceBar, LSwPrice[0], LSwPriceBar, 
                        LastHSwPrice[0], LastHSwPriceBar, LastLSwPrice[0], LastLSwPriceBar, LastHSwDMI[0], LastHSwDMIbar, LastLSwDMI[0], LastLSwDMIbar));
        That way you also don't need the escape characters.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by hazylizard, Today, 08:38 AM
        0 responses
        4 views
        0 likes
        Last Post hazylizard  
        Started by Max238, Today, 01:28 AM
        5 responses
        42 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by giulyko00, Yesterday, 12:03 PM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by habeebft, Today, 07:27 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by AveryFlynn, Today, 04:57 AM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X