Translate For Loop in Easy Language to NT C# - NinjaTrader Programming | futures io social day trading
futures io futures trading


Translate For Loop in Easy Language to NT C#
Updated: Views / Replies:2,145 / 6
Created: by Crassius 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
 

Translate For Loop in Easy Language to NT C#

  #1 (permalink)
Elite Member
Shenandoah Valley, VA
 
Futures Experience: Advanced
Platform: NT7
Broker/Data: AMP, Zen-fire, MB Trading
Favorite Futures: EUR/USD
 
Crassius's Avatar
 
Posts: 13 since Jan 2011
Thanks: 4 given, 1 received

Translate For Loop in Easy Language to NT C#

I'm working on some John Ehler's Easy Language code, and I have reached this section that is so far over my head I'll never be able to translate it.

{Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period.}

InstPeriod = 0;
Value4 = 0;

For count = 0 to 50 begin
Value4 = Value4 + DeltaPhase[count];
If Value4 > 360 and InstPeriod = 0 then begin
InstPeriod = count;
end;
end;

Will you please translate that into C#?


Last edited by Crassius; February 22nd, 2011 at 10:43 PM.
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Pennsylvania, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Forex
 
sunpost's Avatar
 
Posts: 60 since Aug 2010
Thanks: 203 given, 41 received


give this a try...
 
Code
 
int InstPeriod = 0;
int Value4 = 0;
for (int count = 0; count <= 50; count++)
{
     Value4 =+ DeltaPhase[count];
     if (Value4 > 360 && InstPeriod == 0)
     {
          InstPeriod = count;
     }
}

Reply With Quote
The following 2 users say Thank You to sunpost for this post:
 
  #4 (permalink)
Elite Member
Shenandoah Valley, VA
 
Futures Experience: Advanced
Platform: NT7
Broker/Data: AMP, Zen-fire, MB Trading
Favorite Futures: EUR/USD
 
Crassius's Avatar
 
Posts: 13 since Jan 2011
Thanks: 4 given, 1 received

Haven't got it looping yet

Thanks for taking a stab at it Sunpost... who wrote..

int InstPeriod = 0;
int Value4 = 0;
for (int count = 0; count <= 50; count++)
{
Value4 =+ DeltaPhase[count];
if (Value4 > 360 && InstPeriod == 0)
{
InstPeriod = count;
}
}


DeltaPhase is just a double, so I dropped the [count] from DeltaPhase[count] in your answeras that would not compile... looks like the compiler was thinking the [count] was addressing an array... so I have this now...

//Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period.
InstPeriod = 0;
Value4 = 0;

for (int count = 0; count < 50; count++)
{
Value4 =+ DeltaPhase;
DrawTextFixed("Tag1",Value4.ToString(),TextPosition.BottomRight); //for debugging
if (Value4 >360 && InstPeriod == 0)
{
InstPeriod = count;
DsInstPeriod[0] = InstPeriod;
//DrawTextFixed("Tag1",InstPeriod.ToString(),TextPosition.BottomRight);
}
}


The DrawTexts I'm using for debugging... What's happening is that DeltaPhase gets added to Value4 once, and gets drawn, but then the if statement never executes... I believe because the loop doesn't run, doesn't keep adding DeltaPhase to Value4, so Value 4 never gets greater than 360 for the if statement to evaluate to true.

Any help much appreciated.

Reply With Quote
 
  #5 (permalink)
Elite Member
Pennsylvania, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Forex
 
sunpost's Avatar
 
Posts: 60 since Aug 2010
Thanks: 203 given, 41 received

The issue with the statements in the if not being reached after the first time is that InstPeriod gets set to a value other than 0 making the condition (InstPeriod == 0) false.

 
Code
 
if (Value4 >360 &&InstPeriod == 0)
{
    InstPeriod = count;
     DsInstPeriod[0] = InstPeriod;
     //DrawTextFixed("Tag1",InstPeriod.ToString(),TextPos ition.BottomRight);
}

Reply With Quote
 
  #6 (permalink)
Elite Member
Shenandoah Valley, VA
 
Futures Experience: Advanced
Platform: NT7
Broker/Data: AMP, Zen-fire, MB Trading
Favorite Futures: EUR/USD
 
Crassius's Avatar
 
Posts: 13 since Jan 2011
Thanks: 4 given, 1 received

Its often something so small

Thanks for the help sunpost...

I got the loop running.... indicator doesn't look right, but at least its plotting something other than 0. I probably have something wrong up in the ArcTangent math to debug...


what was wrong with the loop was I had

Value4 =+ DeltaPhase;

instead of +=

Progress has been made.... however. Thanks.

Reply With Quote
 
  #7 (permalink)
Elite Member
Pennsylvania, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Forex
 
sunpost's Avatar
 
Posts: 60 since Aug 2010
Thanks: 203 given, 41 received

great progress @Crassius!

You might be interested in a webinar today by @shodson...
Introduction to C# and NinjaScript Programming
Trading Webinar's - Big Mike Trading Forum

Reply With Quote
The following user says Thank You to sunpost for this post:

Reply



futures io > > > > > Translate For Loop in Easy Language to NT C#

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
easy language ..not easy... Serger EasyLanguage Programming 4 April 26th, 2011 04:42 PM
Easy Language.Tradestation to NT DarrenH Traders Hideout 7 December 4th, 2010 04:33 PM
Easy Language to NT/ Futures truth gg80108 NinjaTrader Programming 5 November 21st, 2010 11:04 AM
Easy Language for tradestation esam_jir EasyLanguage Programming 3 November 3rd, 2010 06:22 PM


All times are GMT -4. The time now is 03:13 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-11 in 0.09 seconds with 19 queries on phoenix via your IP 54.226.172.30