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

unable to change order

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

    unable to change order

    ​​ Hi
    I 'm using the bitfiinex livefeed from ninjatools.studio. I get anyway these messages using the following strategy in smaller timeframes.I changed the SamplePriceModification from your site to Enterlong and Entershort. So I'm not shure what is the reason for failure. In my opinion the market is to fast in smaller timeframes (f.e. Renko 100 )? Or should I use OnOrderUpdate/OnExececutionUpdate?

    thx
    regards


    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class SamplePriceModification : Strategy
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Modifying the price of stop loss and profit target orders.";
    Name = "Sample Price Modification";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    StopLossTicks = 20;
    ProfitTargetTicks = 100;
    }
    if (State == State.Configure)
    {
    /* There are several ways you can use SetStopLoss and SetProfitTarget. You can have them set to a currency value
    or some sort of calculation mode. Calculation modes available are by percent, price, and ticks. SetStopLoss and
    SetProfitTarget will submit real working orders unless you decide to simulate the orders. */
    SetStopLoss(CalculationMode.Ticks, StopLossTicks);
    SetProfitTarget(CalculationMode.Ticks, ProfitTargetTicks);
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < BarsRequiredToTrade)
    return;

    // Resets the stop loss to the original value when all positions are closed
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss(CalculationMode.Ticks, StopLossTicks);
    }

    // If a long position is open, allow for stop loss modification to breakeven
    else if (Position.MarketPosition == MarketPosition.Long)
    {
    // Once the price is greater than entry price+50 ticks, set stop loss to breakeven
    if (Close[0] > Position.AveragePrice + 50 * TickSize)
    {
    SetStopLoss(CalculationMode.Price, Position.AveragePrice);
    }
    }

    // Entry Condition: Increasing price along with RSI oversold condition
    if (Close[0] > Close[1] && RSI(14, 3)[0] <= 50)
    {
    EnterLong();
    }

    if (Close[0] < Close[1] && RSI(14, 3)[0] >= 50)
    {
    EnterShort();
    }


    }

    #region Properties
    [Range(1, int.MaxValue)]
    [NinjaScriptProperty]
    [Display(Name="StopLossTicks", Description="Numbers of ticks away from entry price for the Stop Loss order", Order=1, GroupName="Parameters")]
    public int StopLossTicks
    { get; set; }

    [Range(1, int.MaxValue)]
    [NinjaScriptProperty]
    [Display(Name="ProfitTargetTicks", Description="Number of ticks away from entry price for the Profit Target order", Order=2, GroupName="Parameters")]
    public int ProfitTargetTicks
    { get; set; }
    #endregion

    }
    }​

    #2
    Hello hansg1,

    NinjaTools is not an Ecosystem vendor and we cannot assist with anything relating to their connection unfortunately. I would suggest to reach out to that developer if you encounter problems when using this connection. Our support can assist with any supported connection adapters or Ecosystem vendor connections. If the community can otherwise contribute here the thread will remain open for any replies.

    If you are otherwise seeing the problem when using a supported connection or a simulated connection like playback or the simulated data feed we could go into more detail there.

    Please let me know if I may be of additional assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,
      thanks a lot. Is there any Ecosystem vendor for Crypto exchanges/currencies?
      regards

      Comment


        #4
        Hello hansg1,

        You can connect for free to Coinbase by using the connection guide included below:You can view all of the supported brokerages and connections below:
        Let me know if I can provide additional assistance.
        Thomas C.NinjaTrader Customer Service

        Comment


          #5
          Hi ThomasC,
          does Bitmex supports tick data?
          thx
          regarsa

          Comment


            #6
            Hello hansg1,
            Thank you for your post.

            Bitmex has only created an add-on for NinjaTrader 8. You can review Bitmex's documentation on NinjaTrader integration in the publicly available link below:

            Trade Bitcoin and other cryptocurrencies with up to 100x leverage. Fast execution, low fees, Bitcoin futures and swaps: available only on BitMEX.


            For more information, I would suggest contacting Bitmex directly.

            Let me know if I may be of additional assistance.
            Thomas C.NinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,

              I have the same problem with testing coinbase ETH/USD in tick chart without any addon from bitfinex. So for me it looks not as a problem of vendor. And the logic of my script looks for me simple
              open position
              open stop
              open target
              breakeven to open
              reach stop or reach target or reach new input condition
              no rocket science

              Can you help me there anyway?
              thx
              regards
              Attached Files

              Comment


                #8
                Hi Jesse,

                yes as I wrote the same problem with integrated coinbase connection, that means with other connections . It would be nice if you can go into that further.
                thx
                regards

                Comment


                  #9
                  Hello hansg1,

                  Please excuse me I had mis-read that. If you have a specific sample that demonstrates a problem on that connection we can take a look, you would need to attach a .cs or .zip file so we can review it. Its generally suggested to take one of the existing samples like SampleMACrossOver or a very simple script and then add only what is needed to see the error.

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Jesse,

                    the error is only seen, if the strategy is running f.e. on <=100 tick chart on ETHUSD coinbase. And as I said my logic is not complicated:
                    the logic of my script looks for me simple
                    open position( Long or short)
                    open stop
                    open target
                    breakeven to open
                    reach stop or reach target or reach new input condition

                    excuse some "prints" which are not helpful.
                    It is near SampleMACrossOver only with additional setstoploss to Position.AveragePrice in "Long" and "Short" case
                    SetStopLoss(CalculationMode.Price, Position.AveragePrice-( Breakeven-Breakevenplus)* TickSize);
                    Thx
                    regards


                    breakeven1.cs

                    Comment


                      #11
                      Hello hansg1,

                      Thank you for the additional details.

                      I will take a look at the attached script and if I can generate the error I will report that to development.

                      Please let me know if I may be of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Hi Jesse,
                        thanks a lot. It would be nice if you let us know about your results.
                        regards

                        Comment


                          #13
                          Hi Jesse,
                          I I cleaned up the script for better comprehend.
                          I took the template(SamplePriceModification) from your side and changed :


                          thx
                          regards
                          breakeven3j.cs

                          Comment


                            #14
                            what I do not understand : the error tells me stop @1603,40 the log tells me stop @1605.41 and both are below the market?

                            Click image for larger version

Name:	4.PNG
Views:	342
Size:	38.7 KB
ID:	1144587
                            Click image for larger version

Name:	3.PNG
Views:	346
Size:	56.7 KB
ID:	1144586
                            Attached Files

                            Comment


                              #15
                              Hello hansg1,

                              Thank you for the reply.

                              I will try the updated sample today to see if I can hit the error, I am also going to record the instrument for playback so I can retry this under the playback connection in case I hit the error.

                              The error you are seeing for placing the order on the wrong side of the market is possible to hit in fast moving markets depending on the values set in the order methods.

                              Once I have more to report I will reply back here.

                              I look forward to being of further assistance.
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Irukandji, Today, 09:34 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Irukandji  
                              Started by TraderBCL, Today, 04:38 AM
                              3 responses
                              25 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              11 responses
                              1,423 views
                              0 likes
                              Last Post jculp
                              by jculp
                               
                              Started by RubenCazorla, Today, 09:07 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post RubenCazorla  
                              Started by BarzTrading, Today, 07:25 AM
                              2 responses
                              29 views
                              1 like
                              Last Post BarzTrading  
                              Working...
                              X