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

Does not enter the trade

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

  • NinjaTrader_Bertrand
    replied
    Thanks, I don't see an issue per se - with a simple test entry rule for market order like

    // Condition set 1
    if (UpandDowns()[0] >= 1)
    {
    EnterLong(DefaultQuantity, "");
    }

    ...I see it entering trades as expected.

    Leave a comment:


  • andrew-aut1
    replied
    entry condition: plot hitting the value of 1 for going long. Idea is that after a fall in at the first day succeeded by two rises of the two following days will give me the opportunity to get in the market = value 1: My code is as follows : PS: don't get confused: the script has been modified was a script for Keltner Channels in the beginning; thus I couldn't get rid off the variables period and offset Multiplier and they are not of interest.

    Many thx!



    public class UpandDowns : Indicator
    {
    #region Variables
    private int period = 10;
    private double offsetMultiplier = 1.5;
    private DataSeries diff;

    private int timeframe = 390;
    private DataSeries myDataSeries; // Define a DataSeries variable
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(PeriodType.Minute, timeframe);
    //myDataSeries = new DataSeries(this, MaximumBarsLookBack.Infinite);

    Add(new Plot(Color.Blue, "Marker"));
    //Add(new Plot(Color.Red,PlotStyle.Dot, "Marker2"));
    diff = new DataSeries(this);

    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick).
    /// </summary>
    protected override void OnBarUpdate()
    {
    /* Only need to sync DataSeries objects once. We couldn't do this sync in the Initialize() method because we
    cannot access the BarsArray property there. */
    if (diff == null && BarsInProgress == 1)
    {
    /* Syncs another DataSeries object to the secondary bar object.
    We use an arbitrary indicator overloaded with an IDataSeries input to achieve the sync.
    The indicator can be any indicator. The DataSeries will be synced to whatever the
    BarsArray[] is provided.*/
    diff = new DataSeries(SMA(BarsArray[1], 50));
    }
    //checks we have enough bars to calculate
    if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
    return;
    double marker = 0;
    //double marker2 = 0;
    if (BarsInProgress == 0)
    {





    if (CurrentBar < 2)
    return;
    double Open12 = Opens[1][2];
    double Close12 = Closes[1][2];
    double Open11 = Opens[1][1];
    double Close11 = Closes[1][1];
    double Open10 = Opens[1][0];
    double Close10 = Closes[1][0];
    double Open00 = Opens[0][0];
    double Close00 = Closes[0][0];

    if (Open12 > Close12 && Open11 < Close11 && Open10 < Close10)
    {
    marker = marker + 1;
    }

    Marker.Set(marker);

    }


    if (BarsInProgress == 1)
    {
    if (CurrentBar < 2)
    return;


    }




    }

    Leave a comment:


  • koganam
    replied
    Originally posted by andrew-aut1 View Post
    Hey all,

    got a problem I have never had so far. I programmed a simple multitimeframe indicator and its plot is absolutely correct => takes on the value 1 when it should be. (see: screenshot attached) But when I try to backtest the strategy (this indicator == an indicator which only holds the value one => then entry /*which has always worked fine with any other strategy so far*/) it does not enter and I don't know why.

    Has it got something to do with the multiple timeframe concept? Any suggestion what I'm doing wrong?

    Being really grateful for your help,

    Andrew
    What is the error in your log?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    What entry condition would you use here Andrew for the indicator? The plot hitting the value of 1 for going long?

    Leave a comment:


  • andrew-aut1
    started a topic Does not enter the trade

    Does not enter the trade

    Hey all,

    got a problem I have never had so far. I programmed a simple multitimeframe indicator and its plot is absolutely correct => takes on the value 1 when it should be. (see: screenshot attached) But when I try to backtest the strategy (this indicator == an indicator which only holds the value one => then entry /*which has always worked fine with any other strategy so far*/) it does not enter and I don't know why.

    Has it got something to do with the multiple timeframe concept? Any suggestion what I'm doing wrong?

    Being really grateful for your help,

    Andrew
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by Rogers101, 05-05-2024, 11:30 AM
16 responses
50 views
0 likes
Last Post Rogers101  
Started by ninza33, Today, 12:31 PM
2 responses
9 views
0 likes
Last Post ninza33
by ninza33
 
Started by Bobin, 03-12-2024, 08:51 AM
15 responses
481 views
0 likes
Last Post fiddich
by fiddich
 
Started by Skifree, Today, 11:21 AM
4 responses
15 views
0 likes
Last Post Skifree
by Skifree
 
Started by Bogdan097, Today, 03:25 PM
0 responses
8 views
0 likes
Last Post Bogdan097  
Working...
X