dumb piece of code, need better coding - NinjaTrader Programming | futures io social day trading
futures io futures trading


dumb piece of code, need better coding
Updated: Views / Replies:1,057 / 8
Created: by cory Attachments:1

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
 

dumb piece of code, need better coding

  #1 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary

dumb piece of code, need better coding

so I want to store the gap value of each session break into an array, but if I declare double array1[40] Ninja doesn't like it. Then I try to store them into a dataseries except when I go to look for the prior gap value they all get wipe out except the most current gap value, the way i store it is gap[CurrentBar] = gapValue; given gap is a dataseries.

so i end up with this dumb code, is there a better way?

 
Code
                            
// do gap storing into an array

            
if (Cnt == 16)    {
                
gap16 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                    
dsGap[16] = gap16;
                    
dsGap[15] = gap15;
                     
dsGap[14] = gap14;
                    
dsGap[13] = gap13;
                    
dsGap[14] = gap12;
                    
dsGap[12] = gap11;
                    
dsGap[11] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
                if (
Cnt == 15)    {
                
gap15 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                    
dsGap[15] = gap15;
                     
dsGap[14] = gap14;
                    
dsGap[13] = gap13;
                    
dsGap[14] = gap12;
                    
dsGap[12] = gap11;
                    
dsGap[11] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
            if (
Cnt == 14)    {
                
gap14 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                  
dsGap[14] = gap14;
                  
dsGap[13] = gap13;
                  
dsGap[12] = gap12;
                  
dsGap[11] = gap11;
                    
dsGap[10] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
            if (
Cnt == 13)    {
                
gap13 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                  
dsGap[13] = gap13;
                  
dsGap[12] = gap12;
                  
dsGap[11] = gap11;
                    
dsGap[10] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
            if (
Cnt == 12)    {
                
gap12 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                  
dsGap[12] = gap12;
                  
dsGap[11] = gap11;
                    
dsGap[10] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
                if (
Cnt == 11)    {
                
gap11 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                    
dsGap[11] = gap11;
                    
dsGap[10] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
            if (
Cnt == 10)    {
                
gap10 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);
                    
dsGap[10] = gap10;
                      
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
    
            }
            if (
Cnt == 9)    {
                
gap9 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    
                    
dsGap[9]= gap9;
                      
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
            if (
Cnt == 8)    {
                
gap8 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    
                    
dsGap[8]= gap8;
                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
            if (
Cnt == 7)    {
                
gap7 =  Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);

                      
dsGap[7]= gap7;
                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
            if (
Cnt == 6)    {
                
gap6 =  Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    

                      
dsGap[6]= gap6;
                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
            if (
Cnt == 5)    {
                
gap5 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    

                      
dsGap[5]= gap5;
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
            if (
Cnt == 4)    {
                
gap4 =  Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    
        
                      
dsGap[4]= gap4;
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
        
            if (
Cnt == 3)    {
                
gap3 Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    
    
                      
dsGap[3]= gap3;
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
                
            if (
Cnt == 2)    {
                
gap2 =  Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    
    
                     
dsGap[2]= gap2;
                      
dsGap[1]= gap1;
            }
        
            if (
Cnt == 1)    {
                
gap1 =  Instrument.MasterInstrument.Round2TickSize(Open[0] - gapLast);    
                      
dsGap[1]= gap1;
            } 

Reply With Quote
 
  #2 (permalink)
Elite Member
Neubrandenburg, Germany
 
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 297 given, 480 received

i do not know perhaps it helps ...


init from
array[0] ... array[39] has a length of 40

for(int i = 0; i < array.length; i++)
{
read me in or do somethink
}


for better understanding

 
Code
                            

                    dsGap
[15] = gap16
                    
dsGap[14] = gap15
                     
dsGap[13] = gap14
                    
dsGap[12] = gap13
                    
dsGap[11] = gap12
                    
dsGap[10] = gap11
                    
dsGap[9] = gap10
                      
dsGap[8]= gap9
                      
dsGap[7]= gap8
                      
dsGap[6]= gap7
                      
dsGap[5]= gap6
                      
dsGap[4]= gap5
                      
dsGap[3]= gap4
                      
dsGap[2]= gap3
                     
dsGap[1]= gap2
                      
dsGap[0]= gap1

Causality is the relationship between an event (the cause) and a second event (the effect), where the second event is a consequence of the first.

Last edited by wh; January 20th, 2010 at 04:56 AM.
Reply With Quote
 
  #3 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received



cory View Post
so I want to store the gap value of each session break into an array, but if I declare double array1[40] Ninja doesn't like it. Then I try to store them into a dataseries except when I go to look for the prior gap value they all get wipe out except the most current gap value, the way i store it is

You can use double array1[40] , Ninja is fine with that.

Reply With Quote
 
  #4 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


traderwerks View Post
You can use double array1[40] , Ninja is fine with that.

no it gives me a hard time as soon as I type it in
http://content.screencast.com/users/coryng/folders/Jing/media/9ca0301c-004a-42eb-ac7e-867f5c574a0d/2010-01-20_1022.png

ps. I don't think I know how to declare an array properly.

Reply With Quote
 
  #5 (permalink)
Elite Member
Neubrandenburg, Germany
 
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 297 given, 480 received

simple answer

private double[] array1 = new double[40];

or

private double[] array1 = null;

more information can be found here:

http://msdn.microsoft.com/de-de/library/9b9dty7d%28VS.80%29.aspx

know where it stands

Causality is the relationship between an event (the cause) and a second event (the effect), where the second event is a consequence of the first.
Reply With Quote
 
  #6 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


cory View Post
no it gives me a hard time as soon as I type it in

ps. I don't think I know how to declare an array properly.

I was just typing in pseudo code. I meant Ninja does not have a problem with arrays of doubles. You do have to declare/alloc arrays for your language properly before you use them. I should have been clearer.

Reply With Quote
 
  #7 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary

thanks, just what i need , I delete all those dumb code only 5 lines needed.


wh View Post
simple answer

private double[] array1 = new double[40];

or

private double[] array1 = null;

more information can be found here:

Arrays (C#)

know where it stands


Reply With Quote
 
  #8 (permalink)
Elite Member
Florida
 
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
 
Posts: 456 since Jun 2009
Thanks: 1,359 given, 383 received


cory View Post
thanks, just what i need , I delete all those dumb code only 5 lines needed.

that's cool, can you please share the improved version?

kz

Reply With Quote
The following user says Thank You to zeller4 for this post:
 
  #9 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


zeller4 View Post
that's cool, can you please share the improved version?

kz

the whole indicator NoGgapChart or just those 5 lines?

ps. I just remember you know your stuff so here is the whole thing.

Attached Files
Register to download File Type: zip nogapchart.zip (3.6 KB, 13 views)
Reply With Quote
The following user says Thank You to cory for this post:

Reply



futures io > > > > > dumb piece of code, need better coding

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
NinjaScript Coding crazyhorse2393 NinjaTrader Programming 19 August 3rd, 2014 09:11 PM
about multichart coding max-td MultiCharts 3 April 9th, 2010 09:49 AM
The MOST important piece in trading baruchs Psychology and Money Management 13 January 2nd, 2010 04:38 AM
Tradestation Coding Blz17 EasyLanguage Programming 1 September 17th, 2009 02:51 PM
Coding for beginner max-td NinjaTrader Programming 8 July 21st, 2009 07:42 AM


All times are GMT -4. The time now is 02:28 AM.

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-17 in 0.14 seconds with 20 queries on phoenix via your IP 54.82.56.95