Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

info about strategy

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

    info about strategy

    I am trying to built a strategy but I find some problem because the code..
    I have 4 exponential moving average EMA(5) ,EMA(8) ,EMA(18) ,EMA(28) and 3 Momentum Mom(7),Mom(40),Mom(100)
    I had this program in other platform and I would like create the same trading system in ninja trader ,can somobody help me to translate this codes?
    Entry long when : cross((EMA(5)>EMA(18) AND EMA(8)>EMA(28)),0.5)
    AND Mom(7)>0 AND Mom(100)>0

    Exit long when : Cross((EMA(5)<EMA(18) AND EMA(8)<EMA(28)),0,5)
    OR Mom(40)<0

    Entry short when : Cross((EMA(5)<EMA(18) AND EMA(8)<EMA(28)),0.5)
    AND Mom(7)<0 AND Mom(100)<0

    Exit short when : Cross((EMA(5)>EMA(18) AND EMA(8)>EMA(28)),0.5)
    OR Mom(40)>0

    #2
    Hello,

    Give it a try and I will give you pointers if you have questions.

    This code, taken from the SampleMACrossOver Strategy may help you:
    if (CrossAbove(SMA(Fast), SMA(Slow), 1))
    EnterLong();
    elseif (CrossBelow(SMA(Fast), SMA(Slow), 1))
    EnterShort();

    These links may help as well:


    DenNinjaTrader Customer Service

    Comment


      #3
      Thank's to answer..but I opened the link you send me but I not yet understand how can I code more condition together like this:
      cross((EMA(5)>EMA(18) AND EMA(8)>EMA(28)),0.5)
      AND Mom(7)>0 AND Mom(100)>0

      If I well understand this codes it means that the condition would be fulfilled on the first bar when the EMA1>EMA3 and EMA2>EMA4 (in the LongEntryCond1 variable above, for example),cross() function because otherwise condition would be fulfilled for every bar when EMA1>EMA3 and EMA2>EMA4.but I can I write in ninja code?
      Can I do this by strategy wizard?may you explain how?
      Last edited by marino65; 05-16-2009, 12:57 PM.

      Comment


        #4
        Hello,

        Try something like this to include multiple conditions:

        if(time_to_trade && EMA(5)[0] > EMA(18)[0] && EMA(8)[0]>EMA(28)[0])
        {

        EnterLong();
        time_to_trade = false;

        }

        The time_to_trade variable is a bool flag that is assigned a true or false value. You will need to declare and intialize it. You will also need to set it to true upon exiting the trade (neither shown here). This allows for one trade execution at a time.
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        67 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        150 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X