Announcement

Collapse
No announcement yet.

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.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "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.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    155 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    90 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    137 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X