How to get number of positive and negative strings? - futures io
futures io futures trading



How to get number of positive and negative strings?


Discussion in NinjaTrader

Updated by Big Mike
      Top Posters
    1. looks_one zokirb with 3 posts (0 thanks)
    2. looks_two Big Mike with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 MXASJ with 1 posts (0 thanks)
    1. trending_up 2,419 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 5 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to get number of positive and negative strings?

(login for full post details)
  #1 (permalink)
Zagreb Hrvatska
 
Experience: Intermediate
Platform: Ninja Trader
Broker: IB/Ninja
Trading: Crude Oil
 
zokirb's Avatar
 
Posts: 26 since Mar 2011
Thanks: 1 given, 10 received

Question is pretty simple and I'm sure it takes two minutes to write the code, but I'm novice in Ninja programming so please help

I need a code to give me the number of strings of winning trades and the number of strings of losing trades in trades executed by my strategy.

Thank you

Visit my futures io Trade Journal Reply With Quote

Can you help answer these questions
from other members on futures io?
3x Fangdango
Traders Hideout
How to search for a symbol's closing value
EasyLanguage Programming
Thinkscript for scanning in Option Hacker
ThinkOrSwim
QDEL
Stocks and ETFs
Degiro Negative Balance Advice
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on futures io
VWAP for stock index futures trading?
57 thanks
Price Action Kewltech Style
20 thanks
Coronavirus COVID-19
19 thanks
Trying to locate prop firm that purchased my automated trading system
10 thanks
Opinion on iron condor strategy
8 thanks
 
(login for full post details)
  #3 (permalink)
Zagreb Hrvatska
 
Experience: Intermediate
Platform: Ninja Trader
Broker: IB/Ninja
Trading: Crude Oil
 
zokirb's Avatar
 
Posts: 26 since Mar 2011
Thanks: 1 given, 10 received


and here is the non working code....


#region Using declarations
using System;
using System.ComponentModel;
using System.Drawing;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Strategy;
#endregion

namespace NinjaTrader.Strategy
{

[Gui.Design.DisplayName("test")]
public class Test12 : OptimizationType
{
#region variables

private int n;
private int numberOfTrades;
private int numberOfLosingStrings;
private int numberOfWinningStrings;


private double myTrade;
private double myTradeBefore;



#endregion

public override double GetPerformanceValue(SystemPerformance systemPerformance)
{

numberOfTrades = systemPerformance.AllTrades.TradesPerformance.TradesCount;


for ( int n = 0; n < numberOfTrades; n++ )
{
Trade myTrade = systemPerformance.AllTrades[n].ProfitCurrency;
Trade myTradeBefore = systemPerformance.AllTrades[n-1].ProfitCurrency;


if ( myTrade < 0 && myTradeBefore > 0 );
{
numberOfLosingStrings++;
}

if ( myTrade > 0 && myTradeBefore < 0 )
{
numberOfWinningStrings++;
}
}


return numberOfLosingStrings;


}
}
}

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 798 received


zokirb View Post
Question is pretty simple and I'm sure it takes two minutes to write the code, but I'm novice in Ninja programming so please help

I need a code to give me the number of strings of winning trades and the number of strings of losing trades in trades executed by my strategy.

Thank you

By "number of strings" do you mean consecutive winners and losers? You can use the TradesPerformance objects MaxConsecXxx.

int myStringOfLosers = Performance.AllTrades.TradesPerformance.MaxConsecLoser;
int myStringOfWinners = Performance.AllTrades.TradesPerformance.MaxConsecWinner;

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Zagreb Hrvatska
 
Experience: Intermediate
Platform: Ninja Trader
Broker: IB/Ninja
Trading: Crude Oil
 
zokirb's Avatar
 
Posts: 26 since Mar 2011
Thanks: 1 given, 10 received

if trades look like this.... "+" is winner and "-" is loser

++ -- ++++ -- ++++++

there would be three strings of winners and two strings of losers. i'm not looking for max consecutive winners but for number of positive consecutive trades

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
Site Administrator
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,057 since Jun 2009
Thanks: 31,658 given, 95,056 received


zokirb View Post
if trades look like this.... "+" is winner and "-" is loser

++ -- ++++ -- ++++++

there would be three strings of winners and two strings of losers. i'm not looking for max consecutive winners but for number of positive consecutive trades

So basically you would look at the last trade result.

If winner, then increment your _consecutivewinners variable and if a loser then reset your _consecutivewinners variable to 0.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > How to get number of positive and negative strings?


May 27, 2011


Upcoming Webinars and Events
 

An Afternoon With futures io member TropicalTrader

Elite only
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts