NexusFi: Find Your Edge


Home Menu

 





PrintWithTimeStamp problems...


Discussion in NinjaTrader

Updated
    1. trending_up 2,395 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

PrintWithTimeStamp problems...

  #1 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Looking for some help if I may. I want my code to PrintWithTimeStamp when an Entry signal is generated. The following code prints both the Long and Short signals at the same time, and seems to ignore all the code above it such as if (Position.MarketPosition != MarketPosition.Flat) return;.

Here you go:

 
Code
                            
protected override void OnBarUpdate()
{
EntryHandling EntryHandling.UniqueEntries;
 
if (
Bars.FirstBarOfSession)
{
// AllTrades includes virtual and real-time trades. For real-time trades please use .RealtimeTrades
priorTradesCumProfit Performance.AllTrades.TradesPerformance.Currency.CumProfit;
}
 
if (
UseSessionPnL == true && (Performance.AllTrades.TradesPerformance.Currency.CumProfit priorTradesCumProfit >= sessionProfitTarget
|| Performance.AllTrades.TradesPerformance.Currency.CumProfit priorTradesCumProfit <= (-1*sessionLossLimit))) return;
 
if (
Position.MarketPosition != MarketPosition.Flat) return;
 
if (
UseTradeTime==true && ToTime(Time[0]) <= tradeStartTime || ToTime(Time[0]) >= tradeEndTime) return; 
 
if (
GetRandom() == (int) RandomLimit 2)
{
if (
GetRandom2() % == 0)
GoLong();
if (!
Historical)

PrintWithTimeStamp(Instrument.FullName " STRATEGY Erratic NT7: LONG signal generated with ASK at: " GetCurrentAsk()); //For basic TCA
}
else
GoShort();
if (!
Historical)

PrintWithTimeStamp(Instrument.FullName " STRATEGY Erratic NT7:SHORT signal generated with BID at: " GetCurrentBid()); //For basic TCA
}
}
 

Any thoughts on what I'm doing wrong? Thanks!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Quantum physics & Trading dynamics
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


I am not sure what is the exact logic you need but I would definitely take a closer look at your brackets - indentation may prove useful.

Anyway here is my try:
 
Code
                            
if (GetRandom() == (int) RandomLimit 2)
{
    if (
GetRandom2() % == 0)
    {
        
GoLong();
        if (!
Historical)
        { 
            
PrintWithTimeStamp(Instrument.FullName " STRATEGY Erratic NT7: LONG signal generated with ASK at: " GetCurrentAsk()); //For basic TCA
        
}
    }
    else
    {
        
GoShort();
        if (!
Historical)
        { 
            
PrintWithTimeStamp(Instrument.FullName " STRATEGY Erratic NT7:SHORT signal generated with BID at: " GetCurrentBid()); //For basic TCA
        
}
    }


Reply With Quote
Thanked by:
  #4 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

gregid that worked. Thank you! Code is something from the Elite section I'm trying to improve on.

Started this thread Reply With Quote




Last Updated on February 13, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts