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 rdtdale, Today, 01:02 PM
      0 responses
      3 views
      0 likes
      Last Post rdtdale
      by rdtdale
       
      Started by alifarahani, Today, 09:40 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      18 views
      0 likes
      Last Post RookieTrader  
      Started by PaulMohn, Today, 12:36 PM
      0 responses
      8 views
      0 likes
      Last Post PaulMohn  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      41 views
      0 likes
      Last Post love2code2trade  
      Working...
      X