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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X