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

Help

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

    Help

    In chart loaded on NT8, appears yellow instead of green or red on loading in real-time programmatically . Please , is there a way of making this happen.

    IsInstantiatedOnEachOptimizationIteration = true;
    TakeProfit = 8;
    Stoploss = 16;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    EMA1 = EMA(Close, 21);
    EMA2 = EMA(Close, 50);
    EMA1.Plots[0].Brush = Brushes.Yellow;
    EMA2.Plots[0].Brush = Brushes.Lime;
    AddChartIndicator(EMA1);
    AddChartIndicator(EMA2);
    SetProfitTarget(@"EMAshort", CalculationMode.Ticks, TakeProfit);
    SetStopLoss(@"EMAShort", CalculationMode.Ticks, Stoploss, false);
    }

    else if(State==State.Historical)
    {
    load buttons
    }
    OnBarUpdate()

    if (Realtime)
    {
    if(CurrentBar>1)
    {
    if(Position.MarketPosition=MarketPosition.Flat)

    {
    currentpos= 1
    }
    }


    }



    .

    #2
    Hello Emma1,

    Thanks for your post.

    This appears to be a similar inquiry to what you wrote in on.

    When the strategy name is in yellow, this would indicate that the strategy has not completed the last historical trade made prior to the real-time data. For your understanding, when you apply a strategy to a chart, the strategy will begin executing its code on the historical bars first, in sequence, up to the current bar. The trade made historically is virtual (not real) and represents what the strategy would have done. Please see: https://ninjatrader.com/support/help..._account_p.htm
    What happens is that the strategy entered a position and before the position was closed (by the logic of your strategy) it encountered the real-time data. Once the exit conditions occur in real-time and the last virtual trade is closed, the strategy name will turn green indicating it is now ready to trade live. Reference: https://ninjatrader.com/support/help...eStrategiesTab

    How the strategy handles the transition from historical to real-time is called the strategy start behavior and by default is set to "Wait until Flat".
    You can change the strategy start behavior. Please review the choices here: https://ninjatrader.com/support/help..._positions.htm"


    If you prefer, another option to consider would be skipping historical bars processing, you can do this in OnBarUpdate() by:

    if (State == State.Historical) return; // do not process below this line until real time data.

    Reference: https://ninjatrader.com/support/help...nt8/?state.htm

    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by alifarahani, Today, 09:40 AM
    4 responses
    19 views
    0 likes
    Last Post alifarahani  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by PhillT, Today, 02:16 PM
    2 responses
    7 views
    0 likes
    Last Post PhillT
    by PhillT
     
    Started by Kaledus, Today, 01:29 PM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by frankthearm, Yesterday, 09:08 AM
    14 responses
    47 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X