Using negative numbers as private int - NinjaTrader Programming | futures io social day trading
futures io futures trading


Using negative numbers as private int
Updated: Views / Replies:1,751 / 2
Created: by MXASJ Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Using negative numbers as private int

  #1 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Using negative numbers as private int

Hey All,

Having some coding trouble and hoping the community can help before market open tommorow. In one of my strategies, I use Eco2New2 as a filter. The value of Main[0] must be above, say +5 or below -5 to allow a trade. It works long, it doesn't work short.

In region Variables I have this:
...
privateint eco2New2strength = 5; // Default setting for Eco2New2strength
privateint eco2New2strengthneg = -5; // Default setting for Eco2New2strengthneg
...
In my strat (OnBarUpdate) I have this:
...
&& ((ECO2New2(Eco2New2fast, Eco2New2signal, Eco2New2slow).Main[
0]>= Eco2New2strength) || (ECO2New2(Eco2New2fast, Eco2New2signal, Eco2New2slow).Main[0] <= Eco2New2strengthneg))
&& ((ECO2New2(Eco2New2fast, Eco2New2signal, Eco2New2slow).Main[
1]>= Eco2New2strength) || (ECO2New2(Eco2New2fast, Eco2New2signal, Eco2New2slow).Main[1] <= Eco2New2strengthneg))
...

Where I am trying to look at Eco2New2.Main[0] and [1] can create a condition where those values need to be above 5 OR below -5.

In the Properties region I have this:

[Description("")]
[Category(
"Parameters")]
publicint Eco2New2strength
{
get { return eco2New2strength; }
set { eco2New2strength = Math.Max(1, value); }
}
[Description(
"")]
[Category(
"Parameters")]
publicint Eco2New2strengthneg
{
get { return eco2New2strengthneg; }
set { eco2New2strengthneg = value; }
}

Long... I'm good. Its not taking shorts, though, since I realized a coding error and introduced a negative for the variable eco2new2strengthneg.

Any obvious error in my code? Thanks for your time...



Reply With Quote
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,352 given, 83,233 received

When posting code please wrap it in the [ code ] or [ php ] blocks so the spacing doesn't get messed up.

To make a variable a negative value of itself, do this:

 
Code
                            

int strength 
5;
int negstrength = -strength
In other words, if they will always be balanced (+5 and -5) then just put - in front, like -strength. You don't need the extra int even.

Also if you get into trouble the best thing to do is use Print statements. I suggest Printing the values so you can see where the problem lies.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #3 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received


Thanks Mike. Let me try the PHP thing:
 
Code
                            
if (atmStrategyId.Length 0)
{
// You can change the stop price. Added // before the wto lines below to disable.
//if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
// AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
// Print some information about the strategy to the output window
Print(Time[0] + " The current ATM Strategy market position is: " GetAtmStrategyMarketPosition(atmStrategyId));
Print(
Time[0] + " The current ATM Strategy position quantity is: " GetAtmStrategyPositionQuantity(atmStrategyId));
Print(
Time[0] + " The current ATM Strategy average price is: " GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print(
Time[0] + " The current ATM Strategy Unrealized PnL is: " GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
Print(
Time[0] + " Eco Main [0] Value: " ECO2New2(Eco2New2fastEco2New2signalEco2New2slow).Main[0]);
Print(
Time[0] + " Eco Main [1] Value: " ECO2New2(Eco2New2fastEco2New2signalEco2New2slow).Main[1]);

Learning a lot today... OK now back to Ninja Script

Reply With Quote

Reply



futures io > > > > > Using negative numbers as private int

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Berkshire, Other Insurers Get ‘Negative’ Tag from S&P. kbit News and Current Events 0 August 8th, 2011 07:35 PM
Wednesday: Political Paralysis Negative for Markets Quick Summary News and Current Events 0 July 26th, 2011 10:50 PM
Don't say anything negative about a Democrat.... RM99 News and Current Events 0 July 20th, 2011 07:47 PM
How to get number of positive and negative strings? zokirb NinjaTrader Programming 5 May 28th, 2011 12:47 AM


All times are GMT -4. The time now is 05:15 PM.

Copyright © 2017 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
Page generated 2017-12-14 in 0.11 seconds with 19 queries on phoenix via your IP 54.221.73.186