Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleTradeObjects Question

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

    SampleTradeObjects Question

    I'm trying to understand the Trade Class usage and in doing so I've tried using the Reference Sample titled "SampleTradeObjects" but it doesn't seem to do what I believe it is supposed to...or perhaps I need further explaining. My understanding is 'lastThreeTrades' is suppossed to increase or decrease by one, depending on a winner or looser respectively. However, when running the strategy, it often trades 4 contracts, sometimes one contract for four times in a row before increasing, etc. Therefore, I've inserted some Print statements to understand what values were being provided for 'lastThreeTrades' and also what value is given for 'lastThreeTrades++' and 'lastThreeTrades--'
    Can someone explain what this strategy is doing?
    Attached Files

    #2
    Tdschulz, I'm not sure where your cs file is taken from but the original example is found here - http://www.ninjatrader.com/support/f...ad.php?t=19289

    It would stop trading for the day if you had seen 3 losing trades in a row (reset for each session).

    Code:
    /* If lastThreeTrades = -3, that means the last three trades were all losing trades, don't take anymore trades if this is the case. This counter resets every new session, so it only stops trading for the current day. */
    if (lastThreeTrades != -3)
    {
    		if (Position.MarketPosition == MarketPosition.Flat)
    			{
    			// If a new low is made, enter short
    			if (CurrentDayOHL().CurrentLow[0] < CurrentDayOHL().CurrentLow[1])
    				EnterShort();
    					
    			// If a new high is made, enter long
    			else if (CurrentDayOHL().CurrentHigh[0] > CurrentDayOHL().CurrentHigh[1])
    				EnterLong();
    			}
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    575 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X