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

Output Window Print Volume of the entry candle of just the losing Trades

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

    Output Window Print Volume of the entry candle of just the losing Trades

    Hello, I hope you can help me with this. First of all Im not a programer. I'm learning with this ninjatrader!!!

    I need to do 2 things:

    1) I have built an strategy and I have ran it through 180 days. From This Strategy I wish to Print in the outputWindow JUST the Volume of the Entry Candles and Stochastics, ONLY OF THE LOOSING TRADES.

    2) I'm Trying to define a variable that Calculates The average volume of the last 7 Candles

    private VOL VOL1;

    VOL1 = VOL(Close);


    ((VOL1[1] + VOL1[2] + VOL1[3] + VOL1[4] + VOL1[5] + VOL1[6] + VOL1[7]) / 7). Can you please explain me how do I Define this Variable?

    Thanks in advance!!

    Roberto

    #2
    Hello RobertoPaez,

    Thanks for your post.

    One approach would be to save the strategies RealizedPNL (accumulates as the strategy trades) into a variable and at the end of each trade (when you are flat) compare the new realized PNL to the saved PNL in the variable as that would be the difference the last trade made. If the difference is less than zero then it was a losing trade. Here is a link to obtaining the realized PNL of the strategy (that accumulates): https://ninjatrader.com/support/help...?cumprofit.htm

    The other way to determine if the last trade was a losing trade is to check the Trades collection. Please see example 1 on this page: https://ninjatrader.com/support/help...collection.htm If the "last trade" profit is negative it was a losing trade.

    For the variable declaration, you would want to declare the variable as a double type, for example, private double myAvgVolume.

    So then myAvgVolume = ((VOL1[1] + VOL1[2] + VOL1[3] + VOL1[4] + VOL1[5] + VOL1[6] + VOL1[7]) / 7);

    Alternately you could use a simple moving average for this: myAvgVolume = SMA(Volume, 7)[1];
    Volume is a data series, reference: https://ninjatrader.com/support/help...lumeseries.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much!!! I Appreciate it!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kevinenergy, 02-17-2023, 12:42 PM
      118 responses
      2,778 views
      1 like
      Last Post kevinenergy  
      Started by briansaul, Today, 05:31 AM
      0 responses
      9 views
      0 likes
      Last Post briansaul  
      Started by traderqz, Yesterday, 12:06 AM
      11 responses
      28 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by PaulMohn, Today, 03:49 AM
      0 responses
      8 views
      0 likes
      Last Post PaulMohn  
      Started by inanazsocial, Today, 01:15 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Jason  
      Working...
      X