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

Coding structure questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Coding structure questions

    Hello. I have the following code in my OnBarUpdate() method:

    Code:
      if (UpTriangleTimeTakenConverted <= 10000)
        {
            //LASTUPCARAT    
            lastupcarattimetaken = Now.Subtract(lastupcarat);
            if (lastupcarattimetaken <= SpanThreshold)
            {
               
            }
            //LASTUPDOT
            lastupdottimetaken = Now.Subtract(lastupdot);
            if (lastupdottimetaken <= SpanThreshold)
            {
                upprobability++;
            }
            //PRICEBELOWBLUE
            pricebelowbluetimetaken = Now.Subtract(pricebelowblue);
            if (pricebelowbluetimetaken <= SpanThreshold)
            {
                upprobability++;
            }
            //YELBELOWBLUE
            yelbelowbluetimetaken = Now.Subtract(yelbelowblue);
            if (yelbelowbluetimetaken <= SpanThreshold)
            {
                upprobability++;
            }         
            //print arrows*upprobability
    So the value of upprobability will determine how many times I want to print an up arrow. More than 1 arrow per bar should print each subsequent arrow underneath the last arrow by about 2-3 pips. Any idea how I can dynamically structure this statement to accomplish the task? Right now, the y values are hard coded.

    Code:
        DrawArrowUp("Up Arrow5_1" + CurrentBar, 0, Low[0] - .0009, Color.Green);    
            DrawArrowUp("Up Arrow5_2" + CurrentBar, 0, Low[0] - .00012, Color.Green);
            DrawArrowUp("Up Arrow5_3" + CurrentBar, 0, Low[0] - .00015, Color.Green);
            DrawArrowUp("Up Arrow5_4" + CurrentBar, 0, Low[0] - .00018, Color.Green);
            DrawArrowUp("Up Arrow5_4" + CurrentBar, 0, Low[0] - .00021, Color.Green);

    #2
    This is the correct logic
    Code:
    if (UpTriangleTimeTakenConverted <= 10000) 
        { 
            upprobability++; 
            //LASTUPCARAT     
            //Timespan lastupcaratdt=lastupcarat; 
             
            lastupcarattimetaken = Now.Subtract( lastupcarat); 
            if (lastupcarattimetaken <= SpanThreshold) 
            { 
               upprobability++; 
            } 
            //LASTUPDOT 
            lastupdottimetaken = Now.Subtract(lastupdot); 
            if (lastupdottimetaken <= SpanThreshold) 
            { 
                upprobability++; 
            } 
            //PRICEBELOWBLUE 
            pricebelowbluetimetaken = Now.Subtract(pricebelowblue); 
            if (pricebelowbluetimetaken <= SpanThreshold) 
            { 
                upprobability++; 
            } 
            //YELBELOWBLUE 
            yelbelowbluetimetaken = Now.Subtract(yelbelowblue); 
            if (yelbelowbluetimetaken <= SpanThreshold) 
            { 
                upprobability++; 
            }          
            
            //print arrows*upprobability 
            float x=.0006F; 
            for (int h=0; h<=upprobability; upprobability--) { 
                 x+=.003F;             
                DrawArrowUp("Up Diamond2_1" + x, 0, Low[0] - x, Color.Green);     
                 
            }
    ---------
    last up carat vars are defined like this:

    private TimeSpan lastupcarat=TimeSpan.FromSeconds(2);
    private TimeSpan lastupcarattimetaken=TimeSpan.FromSeconds(0);


    On this line:

    lastupcarattimetaken = Now.Subtract( lastupcarat);

    I get error: Cannot implicitly convert System.DateTime to System.Timespan

    Comment


      #3
      Unfortunately this is beyond the level of support we offer - did you check into MSDN already? I would guess lastupcarat needs to be DateTime instead of TimeSpan though...
      BertrandNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      3 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Working...
      X