Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Josh please, help me

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

    Josh please, help me

    Hi guys, I'm an italian student adm i'm improving my thesys about trading system. I developed my code in easylanguage and now i'm trying to , translate it in C# for ninjia . I compile the code but when apply it on chart ninjia doesn't provide the signals.I think there are mistakes about ninja script...It's symple long/short limt order es long next open +(stddev(High-low)*Mul) if Ema fast > Ema slow .
    Josh please can you help me?
    Attached Files

    #2
    As you run the strategy --> Are there any error messages generated in the NinjaTrader Control Center log tab?
    RayNinjaTrader Customer Service

    Comment


      #3
      Thannks Ray for the reply, i wrote the code and compile it, without problem, but when i apply it in simulation Ninjia doesn't provide the signal...This is the central of my code if you could help me...to solve the problem


      private int mlt = 2; // Default setting for Mlt
      private
      int lenta = 50; // Default setting for Lenta
      private
      int veloce = 10; // Default setting for Veloce
      private
      int giorni = 5; // Default setting for Giorni
      double
      Value1;
      double
      Value2;
      private
      DataSeries HighMenoOpen;
      private
      DataSeries OpenMenoLow;
      // 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>
      protected
      overridevoid Initialize()
      {
      SetProfitTarget(
      "", CalculationMode.Price, Mlt*StdDev(High, 5)[0]);
      CalculateOnBarClose =
      true;
      }
      ///
      <summary>
      ///
      Called on each bar update event (incoming tick)
      ///
      </summary>
      protected
      overridevoid OnBarUpdate()
      {
      HighMenoOpen.Set(High[
      1] - Open[1]);
      OpenMenoLow.Set(Open[
      1] - Low[1]);
      Value1 = StdDev(HighMenoOpen , giorni)[
      1];
      Value2 = StdDev(OpenMenoLow , giorni)[
      1];
      // Condition set 1
      if (EMA(Veloce)[1] > EMA(Lenta)[1] && Position.MarketPosition!=MarketPosition.Long);
      {
      EnterLongLimit(
      1,Open[0] - (Value2 * Mlt));}
      if
      (Position.MarketPosition==MarketPosition.Long)
      {
      ExitLongLimit(Open[
      0] + (Value1 * Mlt));
      }
      // Condition set 2
      if
      (EMA(Veloce)[1] < EMA(Lenta)[1] && Position.MarketPosition!=MarketPosition.Short);
      {
      EnterShortLimit(
      1,Open[0] + (Value1 * Mlt));}
      if
      (Position.MarketPosition==MarketPosition.Short)
      {
      ExitShortLimit(Open[
      0] - (Value2 * Mlt));
      }
      }

      Comment


        #4
        This likely will help - http://www.ninjatrader-support.com/v...ead.php?t=3170
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by giucol View Post
          This method is used to configure the strategy and is called once before any strategy method is called.
          ///
          </summary>
          protected overridevoid Initialize()
          {
          SetProfitTarget("", CalculationMode.Price, Mlt*StdDev(High, 5)[0]);
          CalculateOnBarClose = true;
          }
          Hi giucol,

          you use an indicator's return value from StdDev() in SetProfitTarget() in Initialize(). Initialize() is called before your strategy starts. So, what do you expect StdDev() to return during initialization? I guess it wouldn't return a useful result anyway?

          Regards
          Ralph

          Comment


            #6
            Ralph you have reason, i have to delete Set profit target..., but i think the problem is in the code about Value1 and Value2 because i neeed to catch the standard deviation of high meno Open for value1 and standard deviation of Open meno low for value2, I used data series
            HighMenoOpen and OpenMenoLow, the compile is ok, but i dont know if that's ok.
            I also make an indicator to plot Value1 and Value2, the compile is ok but Ninjia doesn't plot nothing...
            Please help me , safe me...

            Comment


              #7
              Hi giucol,

              you declare two DataSeries variables (HighMenoOpen, OpenMenoLow) and you use it in OnBarUpdate() as class instances without instantiation. Don't think this works. For an class instantiation example look at the "Reference Samples" section. There is a packet "Synchronizing a DataSeries object to a secondary time frame". It explains how and where to generate a DataSeries class instance.

              Regards
              Ralph

              Comment


                #8
                To Indicate Next Bar

                THANKS RALPH I SOLVE THE PROBLEM TO PLOT VALUE 1 AND A VaLUE 2...NOW I NEED TO IMPLEMENT MY STRATEGY, I NEED TO INSERT AN ORDER LIMIT..IN EASY LANGUAGE CODE Buy ("LongScalp") next bar at open of next bar -
                (Value2*Mlt) limit;
                I wrote in C# this code for next Open
                if (EMA(Veloce)[0] > EMA(Lenta)[0] && Position.MarketPosition!=MarketPosition.Long);
                {
                EnterLongLimit(
                1,Open[-1] - (Value2 * Mlt));}

                if
                (Position.MarketPosition==MarketPosition.Long)
                {
                ExitLongLimit(Open[-1
                ] + (Value1 * Mlt));

                I don't if i can use to indicate next bar -1
                Please help me, andyou don't hate me....

                Comment


                  #9
                  Never fear, no reason to hate you.

                  You can't access a bar in the future (would be a nice feature to return the prices of a future bar). But you can find out if a new bar has started by property "FirstTickOfBar". In the help-section of NT there is a little example how to use it.

                  Regards
                  Ralph

                  Comment


                    #10
                    Thanks Ralph, i tried to aplly the code with
                    if (EMA(Veloce)[0] > EMA(Lenta)[0] && Position.MarketPosition!=MarketPosition.Long);
                    {
                    EnterLongLimit(
                    1,Open[-1] - (Value2 * Mlt));}
                    if(Position.MarketPosition==MarketPosition.Long)
                    {
                    ExitLongLimit(Open[-
                    1] + (Value1 * Mlt));
                    }

                    and now ninja gives me the signal....but do you tink that open[-1] is a mistake?
                    Pease can you tell me the section about "FirstTickOfBar"...Thanks Ralph

                    Comment


                      #11
                      Originally posted by giucol View Post
                      ...and now ninja gives me the signal....but do you tink that open[-1] is a mistake?
                      Pease can you tell me the section about "FirstTickOfBar"...
                      I think first element of an open[]-array has the index number 0. If -1 works too, then you could check whether it contains the correct number. I wouldn't expect that. But, when you ever run this strategy in real time (and not only for backtesting) a reference into the future can never work.

                      FirstTickOfBar is described under:
                      NinjaScript
                      NinjaScript Language Reference
                      Shared Data Methods and Properties

                      Alternatively you can use the search function.

                      Regards
                      Ralph

                      Comment


                        #12
                        No Backtesting

                        Ralph, excuse me if i annoy you... i tried the code not in backtesting but in simulation data feed, so in real time and gives me the signal, but is possible that read -1 as 0...so don't catch next open

                        Comment


                          #13
                          Unfortunately negative "barsAgo" indexes are not support. You'll see an error in your logs.

                          Comment


                            #14
                            Dierk the strategy gives me signals, also if i write O[-1], so if i can't use Open[-1] how can i say to ninja to entry in a specific level that includes the next open + (Sell limit) or - (Buy limit) something if i cant use -1?
                            Excuse me to all, thanks ...

                            Comment


                              #15
                              Unfortunately you can not use/access a price value in the future. This is not supported.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              580 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              335 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              102 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              552 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X