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