Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Performance.AllTrades[Performance.AllTrades.Count - 1].ProfitCurrency >0 not working

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

    Performance.AllTrades[Performance.AllTrades.Count - 1].ProfitCurrency >0 not working

    Help please.
    I have CODE:
    Code:
    	
    Print("N= " + N + ";  VOLMA= " + ((EMA(Volume, 5)[0] < EMA(Volume, 5)[1]) && (EMA(Volume, 5)[1] < EMA(Volume, 5)[2])) +
    ";       NBars= " + numberOfBars+ "  TIME:" + Time[0] +
    "    PROF=  " + Curr + " T/F="+ (Curr > 0) + 
    ";   MPos="+ Position.MarketPosition +  
    ";   AllTrades " +Performance.AllTrades.Count);
    		
    if (Performance.AllTrades.ByDay.Count <1 &&
    Open[0] > Close[0])
    {
    N=1;
    SetProfitTarget("", CalculationMode.Ticks, TP);
    SetStopLoss("", CalculationMode.Ticks, SL, false);
    EnterLong(N, "");	
    }						
    if (Performance.AllTrades.ByDay.Count >= 1)
    Curr = Performance.AllTrades[Performance.AllTrades.Count - 1].ProfitCurrency;
    
    // Enter Long  if LastWin
    if (Bars.BarsSinceSession > 40 &&
    Performance.AllTrades[Performance.AllTrades.Count - 1].ProfitCurrency > 0 &&				
    Open[0] > Close[0] &&
    Position.MarketPosition == MarketPosition.Flat &&
    EMA(Volume, 5)[0] > EMA(Volume, 5)[1] && EMA(Volume, 5)[1] < EMA(Volume, 5)[2] || EMA(Volume, 5)[1] > EMA(Volume, 5)[2] &&
    EMA(Volume, 5)[0] < EMA(Volume, 5)[1] && EMA(Volume, 5)[1] > EMA(Volume, 5)[2] &&
    SMA(5)[0] > SMA(7)[0])
    
    { 									
    N=1;
    SetProfitTarget("", CalculationMode.Ticks, TP);
    SetStopLoss("", CalculationMode.Ticks, SL, false);
    EnterLong(N, "");
    So if (Performance.AllTrades[Performance.AllTrades.Count - 1].ProfitCurrency > 0)
    than EnterLong.
    But it enter all the time even when it's not true.


    Here is out put window:

    N= 1; VOLMA= True; NBars= 1 TIME:01.08.2016 2:45:00 PROF= 0 T/F=False; MPos=Flat; AllTrades 0
    N= 1; VOLMA= False; NBars= 2 TIME:01.08.2016 2:50:00 PROF= 0 T/F=False; MPos=Flat; AllTrades 0
    N= 1; VOLMA= False; NBars= 3 TIME:01.08.2016 2:55:00 PROF= 0 T/F=False; MPos=Flat; AllTrades 0
    N= 1; VOLMA= False; NBars= 4 TIME:01.08.2016 3:00:00 PROF= 0 T/F=False; MPos=Long; AllTrades 0
    N= 1; VOLMA= False; NBars= 5 TIME:01.08.2016 3:05:00 PROF= 0 T/F=False; MPos=Flat; AllTrades 1
    N= 1; VOLMA= False; NBars= 6 TIME:01.08.2016 3:10:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 1
    N= 1; VOLMA= False; NBars= 7 TIME:01.08.2016 3:15:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 1
    N= 1; VOLMA= False; NBars= 8 TIME:01.08.2016 3:20:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 1
    N= 1; VOLMA= False; NBars= 9 TIME:01.08.2016 3:25:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 1
    N= 1; VOLMA= True; NBars= 10 TIME:01.08.2016 3:30:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 1
    N= 1; VOLMA= True; NBars= 11 TIME:01.08.2016 3:35:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 1
    N= 1; VOLMA= True; NBars= 12 TIME:01.08.2016 3:40:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 1
    N= 1; VOLMA= False; NBars= 13 TIME:01.08.2016 3:45:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 2
    N= 1; VOLMA= False; NBars= 14 TIME:01.08.2016 3:50:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 2
    N= 1; VOLMA= False; NBars= 15 TIME:01.08.2016 3:55:00 PROF= 37,5 T/F=True; MPos=Long; AllTrades 2
    N= 1; VOLMA= False; NBars= 16 TIME:01.08.2016 4:00:00 PROF= 37,5 T/F=True; MPos=Long; AllTrades 2
    N= 1; VOLMA= False; NBars= 17 TIME:01.08.2016 4:05:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 3
    N= 1; VOLMA= True; NBars= 18 TIME:01.08.2016 4:10:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 3
    N= 1; VOLMA= True; NBars= 19 TIME:01.08.2016 4:15:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 3
    N= 1; VOLMA= False; NBars= 20 TIME:01.08.2016 4:20:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 4
    N= 1; VOLMA= False; NBars= 21 TIME:01.08.2016 4:25:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 4
    N= 1; VOLMA= False; NBars= 22 TIME:01.08.2016 4:30:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 4
    N= 1; VOLMA= False; NBars= 23 TIME:01.08.2016 4:35:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 4
    N= 1; VOLMA= True; NBars= 24 TIME:01.08.2016 4:40:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 5
    N= 1; VOLMA= True; NBars= 25 TIME:01.08.2016 4:45:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 5
    N= 1; VOLMA= False; NBars= 26 TIME:01.08.2016 4:50:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 5
    N= 1; VOLMA= False; NBars= 27 TIME:01.08.2016 4:55:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 5
    N= 1; VOLMA= False; NBars= 28 TIME:01.08.2016 5:00:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 5
    N= 1; VOLMA= False; NBars= 29 TIME:01.08.2016 5:05:00 PROF= -37,5 T/F=False; MPos=Long; AllTrades 5
    N= 1; VOLMA= False; NBars= 30 TIME:01.08.2016 5:10:00 PROF= -37,5 T/F=False; MPos=Flat; AllTrades 6
    N= 1; VOLMA= False; NBars= 31 TIME:01.08.2016 5:15:00 PROF= 37,5 T/F=True; MPos=Flat; AllTrades 6

    Please, can you tell me why?

    #2
    Hello,
    From the code provided I do not see any logic errors. Can you clarify what your prints are? Are one of your prints the profit value that you are using to base your trades around?
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X