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

Need help with time-out after every trade

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

    Need help with time-out after every trade

    Hello again!
    I solved my another problems with time-frames, but now I need help with timeout after each trade.

    I tried BarsSinceEntry() and BarsSinceExit() , but when I did it like in the example - I have no enters from my Strategy at all! Can you help me to get time-out in my Strategy?
    Here is a code what I'm using to entry in any trades.

    PHP Code:
    if(!IsLongTrend){
                        if(
    price _numLow && GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat){// upper then green line
                            //if(GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat){
                            //    Print ("HAVE ANY ORDER");
                            //}
                            //else 
                            
    if(GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat){
                                
    //atmStrategyId = GetAtmStrategyUniqueId();
                                //orderId = GetAtmStrategyUniqueId();
                                
    AtmStrategyCreate(OrderAction.SellOrderType.Market00TimeInForce.DayorderId"AqueGenNinjaStrategy"atmStrategyId);
                                
    startOrderPrice price;
                                
    openedOrderId orderId;
                                
    isOrderPresent true;
                            }
                        }
                    }
            else 
                    if(
    IsLongTrend){
                        if(
    price _numHigh && GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat){
                            
    //if(GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat){
                            //    Print ("HAVE ANY ORDER");
                            //}
                            //else 
                            
    if(GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat){
                                
    //atmStrategyId = GetAtmStrategyUniqueId();
                                //orderId = GetAtmStrategyUniqueId();
                                
    AtmStrategyCreate(OrderAction.BuyOrderType.Market00TimeInForce.DayorderId"AqueGenNinjaStrategy"atmStrategyId);
                                
    startOrderPrice price;
                                
    openedOrderId orderId;
                                
    isOrderPresent true;
                            }
                        }
                    } 
    What I need to write and where to get this time-out thing happened?

    Big thanks!

    UPDATE: I found that BarsSinceExit() doesn't works with ATM. So are there any alternative method to use for time-out after each trade?
    Last edited by YevhenShynkarenko; 03-25-2015, 04:04 AM.

    #2
    Hello,

    Thank you for the question.

    Because ATM strategies work differently than a managed order, the BarsSinceEntry and Exit would not work as there is not a signal name to track.

    Instead you could use a variable, when you submit the entry save the CurrentBar as a variable that can be used later.

    You could then check if the CurrentBar is greater than the saved bar plus the number of bars you want for the timeout.

    Here is a simple example of what I mean:

    Code:
    if(CurrentBar > savedBar + 5)
    {
    // do some action. 
    }
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by snoussi, Today, 12:26 PM
    0 responses
    1 view
    0 likes
    Last Post snoussi
    by snoussi
     
    Started by SnailHorn, 05-02-2024, 10:49 PM
    3 responses
    27 views
    0 likes
    Last Post SnailHorn  
    Started by giulyko00, Today, 11:49 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by marksingh87, 02-13-2024, 04:55 PM
    6 responses
    211 views
    1 like
    Last Post mshrstv
    by mshrstv
     
    Started by SnailHorn, Today, 08:38 AM
    2 responses
    4 views
    0 likes
    Last Post SnailHorn  
    Working...
    X