Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help programmazione

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

  • NinjaTrader_Tim
    replied
    Hi Italy,

    Unfortunately, I cannot debug this for you.

    First, are you getting any errors in the Log while running the script?

    Ensure your condition are being met by placing Print()s in them.
    More info at - http://www.ninjatrader.com/support/f...ead.php?t=3418

    Leave a comment:


  • Italy
    started a topic Help programmazione

    Help programmazione

    Hello,
    I wrote a code for practice, below, says that to operate if the inclination is increasing dell'ADX:
    Long if the slope of the SMA is 9> inclination of SMA 25 and MACD> its 10 EMA
    Short if the slope of the SMA 9 is <than the SMA 25 and the MACD <10 of their EMA
    Pressing the F5 key tells me OK, but when I focus on the graph, not doing anything long or short.
    Why?
    Thank you.
    Ciao.
    Roberto
    #region Variables

    private double livello1 = 0;
    private double livello1B = 0;
    private double livello2 = 0;
    private double livello3 = 0;
    private int ave = 0;
    #endregion
    protected override void Initialize()
    {
    Add(ADX(30));
    Add(ADX(30));
    Add(SMA(9));
    Add(SMA(9));
    Add(SMA(20));
    Add(SMA(20));
    Add(MACD(10, 25, 9));
    Add(MACD(10, 25, 9));

    CalculateOnBarClose = true;
    }

    #region CalcoliValori
    private double Valore1()
    {
    return (ADX(30)[0]- ADX(30)[1])/ADX (30) [1];
    }
    private double Valore1B()
    {
    return (ADX(30)[1]- ADX(30)[2])/ADX (30) [2];
    }


    private double Valore2()
    {
    return (SMA(9)[0]-SMA(9)[1])/SMA(9)[1];
    }


    private double Valore3()
    {
    return (SMA(20)[0]-SMA(20)[1])/SMA(20)[1];
    }


    #endregion

    #region OrderRouting
    private void GestisciOrdini()
    {
    if (ADX(30)[0] != 0 && ADX(30)[1] != 0)

    Valore1();
    double livello1;

    if (ADX(30)[1] != 0 && ADX(30)[2] != 0)

    Valore1B();
    double livello1B;


    if (SMA(9)[1]!= 0 && SMA(9)[0] != 0)
    {
    Valore2();
    double livello2;
    }



    if (SMA(20)[1] != SMA(20)[0])
    {
    Valore3();
    double livello3;
    }


    }


    #endregion

    protected override void OnBarUpdate()
    {
    GestisciOrdini();


    if( livello1 > livello1B && livello2 > livello3 && MACD(10, 25, 9).Avg[0] >SMA(MACD(10, 25, 9).Avg, 14)[0])
    {
    EnterLong(1, "ingresso Long ADX");
    }


    if ( livello1 > livello1B && livello2 < livello3 && MACD(10, 25, 9).Avg[0] < SMA(MACD(10, 25, 9).Avg, 14)[0])
    {
    EnterShort(1, "ingresso short ADX");
    }



    if (Position.MarketPosition == MarketPosition.Long && MACD(10, 25, 9).Avg[0] < SMA(MACD(10, 25, 9).Avg, 14)[0])
    {
    ExitLong("uscita long", "");
    }


    if (Position.MarketPosition == MarketPosition.Short && MACD(10, 25, 9).Avg[0] > SMA(MACD(10, 25, 9).Avg, 14)[0])
    {
    ExitShort("uscita short", "");
    }
    }
    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public double Livello1
    {
    get { return livello1; }
    set { livello1 = Math.Max(100,value); }
    }
    [Description("")]
    [GridCategory("Parameters")]
    public double Livello1B
    {
    get { return livello1B; }
    set { livello1B = Math.Max(100,value); }
    }
    [Description("")]
    [GridCategory("Parameters")]
    public double Livello2
    {
    get { return livello2; }
    set { livello2 = Math.Max(100,value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public double Livello3
    {
    get { return livello3; }
    set { livello3 = Math.Max(100,value); }
    }
    [Description("")]
    [GridCategory("Parameters")]
    public int Ave
    {
    get { return ave; }
    set { ave = Math.Max(100,value); }
    }



    #endregion
    }
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by NinjaTrader_Kate, Today, 02:40 PM
0 responses
5 views
0 likes
Last Post NinjaTrader_Kate  
Started by aligator, Today, 02:09 PM
1 response
12 views
0 likes
Last Post NinjaTrader_Kate  
Started by patpat, Today, 11:34 AM
1 response
6 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by crystalet, Today, 10:41 AM
3 responses
14 views
0 likes
Last Post crystalet  
Started by tonynt, Today, 10:47 AM
3 responses
16 views
0 likes
Last Post NinjaTrader_ChrisL  
Working...
X