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

Price Entry and EMA Close

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

    Price Entry and EMA Close

    I created the below with the Strategizer for trading the FOREX. The purpose is to create an entry after an EMA crossing opportunity for the entry point has passed. I want to enter a trade short at the current price and have the trade exit on the EMA crossabove of the 5,6 ema's.

    The programming has created three unusual problems when activated in the Sim mode during active trading times. I entered the the GBPUSD pair short when it was trading at 1.9932. I was instantly showing a $154.00 profit as the trade was showing the crossbelow ENTRY point of 2.0086 (which was missed), 154 pips above my present entry point. How can I get the program to enter at the current price and start from there?

    It is also filling trades concurrently in the 1,10,15 min along with the intended 60 min interval. The 1, 10, 15 fills have a "start" next to them. The 60 has a "stop" as would be normal.

    The third observation is the strategy looks to be backtesting on it's own during the strategy activation and shows the entry marks throughout the various intervals.

    My priority here is to get the PRICE entry to work properly.


    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    ///<summary>
    /// PRICE Entry SHORT EMA exit 56LONG
    ///</summary>
    [Description("PRICE Entry SHORT EMA exit 56LONG")]
    [Gui.Design.DisplayName("PRICE Entry SHORT EMA exit56LONG")]
    publicclass PriceEntryShortEMAExit56LONG : Strategy
    {
    #region Variables
    // Wizard generated variables
    privateint entryPrice = 1; // Default setting for EntryPrice
    privateint fast = 5; // Default setting for Fast
    privateint slow = 6; // Default setting for Slow
    // User defined variables (add any user defined variables below)
    #endregion
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(EMA(5));
    Add(EMA(6));
    CalculateOnBarClose = true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (EntryPrice <= GetCurrentBid())
    {
    EnterShort(DefaultQuantity, "");
    PlaySound(@"C:\Program Files\NinjaTrader 6\sounds\OrderFilled.wav");
    }
    // Condition set 2
    if (CrossAbove(EMA(5), EMA(6), 1))
    {
    ExitShort("", "");
    PlaySound(@"C:\Program Files\NinjaTrader 6\sounds\TargetFilled.wav");
    }
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by trilliantrader, 04-18-2024, 08:16 AM
4 responses
18 views
0 likes
Last Post trilliantrader  
Started by mgco4you, Today, 09:46 PM
1 response
7 views
0 likes
Last Post NinjaTrader_Manfred  
Started by wzgy0920, Today, 09:53 PM
0 responses
9 views
0 likes
Last Post wzgy0920  
Started by Rapine Heihei, Today, 08:19 PM
1 response
10 views
0 likes
Last Post NinjaTrader_Manfred  
Started by Rapine Heihei, Today, 08:25 PM
0 responses
10 views
0 likes
Last Post Rapine Heihei  
Working...
X