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

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 Tim-c, Today, 02:10 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    2 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    50 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    10 responses
    399 views
    1 like
    Last Post beobast
    by beobast
     
    Started by lorem, Yesterday, 09:18 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X