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

Strategy deployment for Micro Futures

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

    Strategy deployment for Micro Futures

    Hello,

    I am using a bar counter to exit a trade when long or short.

    The strategy works fine during back- testing but when running real time exits the trade a few bars too early.

    Please find below a part of my code

    ---------------------
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    BarsExitLong = 35;
    BarsExitShort = 15;
    }
    }

    protected override void OnBarUpdate()
    {
    if (IsShort)
    {
    barsShort ++;

    if ( (barsShort >= BarsExitShort) && (Close[0] < (Position.AveragePrice - _atr[0]) ) )
    {
    base.ExitShort("STarget" + barsShort, "S1");
    }
    }

    if (IsFlat && (_smaS[2]<=_smaS[1]) && (_smaS[1] > _smaS[0]) )
    {
    int lots;

    barsShort = 0;

    double Ptarget = Close[0] - ProfitMultiplier;


    if (TradingFutures)
    {
    lots = (int) (InitialCapital / 50000);

    shortEntryOrder1 = EnterShort( lots , "S1");

    stopPrice = High[0] + ATRMultiplier;

    base.SetStopLoss("S1", CalculationMode.Price, stopPrice, false );
    }
    }
    }
    -----------------------------


    I suspect that the reason for this is the fact that I am running the strategy in real time on eurex regular trading hours while the program is computing the bars in extended trading hours.


    In this particular instance in the attached photo the trade was exited after 11 bars while the programming was for 15 bars.


    Please advise and why this is happening and how to rectify.

    Kind regards

    Ioannis

Latest Posts

Collapse

Topics Statistics Last Post
Started by bmartz, 03-12-2024, 06:12 AM
5 responses
32 views
0 likes
Last Post NinjaTrader_Zachary  
Started by Aviram Y, Today, 05:29 AM
4 responses
13 views
0 likes
Last Post Aviram Y  
Started by algospoke, 04-17-2024, 06:40 PM
3 responses
28 views
0 likes
Last Post NinjaTrader_Jesse  
Started by gentlebenthebear, Today, 01:30 AM
1 response
8 views
0 likes
Last Post NinjaTrader_Jesse  
Started by cls71, Today, 04:45 AM
1 response
7 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X