Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

dll problem

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

    dll problem

    I'm running the following code in Tradestation 8.2:

    inputs:
    size(1);

    variables:
    marktpos(0),
    OrderID ("");

    marktpos =NTMarketPosition("AB1234");

    if marktpos=0 then begin
    OrderID ="EnterShort";
    value1 =NTSellMarket(OrderId,size);
    end;

    if marktpos=1 then begin
    OrderID ="EnterShort";
    value1 =NTSellMarket(OrderId,2);
    end;

    if marktpos=-1 then begin
    OrderID ="ReverseShort";
    value1 =NTBuyMarket(OrderId,2);
    end;

    I have the indicator set to update at end of bar, not every tick. It is supposed to just test the interface by entering short first then reversing at the close of every bar. When I deploy it, it sends off a zillion orders about a second apart, all short with quantity =1. I wind up with lots of contracts in my simulation account and programs not responding.. I have another indicator plotting marketposition and it never gets the position, it reads "0" all the time so it appears that the above code never updates the marketpostion and it also sends off orders intrabar when it should only send them at the end of the bar.

    #2
    Make sure that you submit orders only if current bar is last bar.
    RayNinjaTrader Customer Service

    Comment


      #3
      oops, sorry. I've been doing Tradestation coding for years, still forget things like that.

      Comment


        #4
        The code is now:


        inputs:
        size(1);

        variables:
        marktpos(0),
        OrderID ("");

        marktpos =NTMarketPosition("DU1087");

        if lastbaronchart then begin
        if marktpos=0 then begin
        OrderID ="EnterLong";
        value1 =NTSellMarket(OrderId,size);
        end;

        if marktpos=1 then begin
        OrderID ="EnterShort";
        value1 =NTSellMarket(OrderId,2);
        end;

        if marktpos=-1 then begin
        OrderID ="ReverseShort";
        value1 =NTBuyMarket(OrderId,2);
        end;
        end;

        Plot1(marktpos,"Position",green);

        Now, at the end of every bar it sends off a market order, size =1; It does not seem to ever know that the marketposition is other than flat.

        Comment


          #5
          Positions are only reported if the position was initiated through the ATI.
          Restart NT and try again. I would also point out our sample code (in HelpGuide and should also be NTSample strategy in TS), run that and modify from there as a learning approach.
          RayNinjaTrader Customer Service

          Comment


            #6
            I flattened the position with IB and restarted NT and had same problem, restarted whole computer and had the same problem. Here is the code as currently running:


            inputs:
            size(1);

            variables:
            marktpos(0),
            OrderID ("");

            marktpos =NTMarketPosition("AB1234");

            if lastbaronchart then begin
            if marktpos=0 then begin
            OrderID ="EnterLong";
            value1 =NTSellMarket(OrderId,size);
            end;

            if marktpos=1 then begin
            OrderID ="EnterShort";
            value1 =NTSellMarket(OrderId,2);
            end;

            if marktpos=-1 then begin
            OrderID ="ReverseShort";
            value1 =NTBuyMarket(OrderId,2);
            end;
            end;
            Plot1(marktpos,"Position",green);

            It just keeps on selling one contract and never seems to get the idea that the marketposition is anything other than zero. In TWS and in NT Control Center it is reported that the marketposition is short and both of those update promptly with every bar's new order.... I don't see where I am doing anything differently than the NT sample strategy except I am running an indicator to call the NTdll code...
            Last edited by maxpi; 07-25-2007, 11:31 AM.

            Comment


              #7
              Flatten IB, restart NT, run the NTSample strategy for verification that it will work. If not, please let me know otherwise use this template as a starting point.

              Thanks in advance.
              RayNinjaTrader Customer Service

              Comment


                #8
                I flattened with IB, restarted Control Center, connected to IB, the AT interface is enabled. I installed the Sample Strategy and get no orders, I installed the Sample Indicator and also get no orders... This is running on volume bars in TS I will switch it to minute bars, TS has problems with volume bars come to think of it, I thought it was all related to intrabar trading but maybe not...


                OK, on minute bars end of bar, it works, on volume bars it does not work end of bar. I'll try it in Multicharts... that is more my focus nowadays than Tradestation...

                Comment


                  #9
                  The NTSample Strategy does not send any orders from Multicharts at all, not on 30 minute charts or volulme bars. I know you don't support Multicharts but it's a just a side note..

                  Comment


                    #10
                    Can I trade from volume bars with NT

                    I'm working to find a platform that will autotrade from volume bars, intrabar, preferrably from an indicator. Will NinjaTrader do that for me, assuming I can write the C# code?

                    Comment


                      #11
                      Yes, NT supports tick by tick strategies on Volume bars.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Too cool..

                        It's nice working with professionals

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by andrewtrades, Today, 04:57 PM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by chbruno, Today, 04:10 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Started by josh18955, 03-25-2023, 11:16 AM
                        6 responses
                        436 views
                        0 likes
                        Last Post Delerium  
                        Started by FAQtrader, Today, 03:35 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post FAQtrader  
                        Started by rocketman7, Today, 09:41 AM
                        5 responses
                        20 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X