• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TradeStation Code => Ninjatrader 8

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

    TradeStation Code => Ninjatrader 8

    The code below is Tradestation code from few years ago. But looking through it, it should be easily convertible to Ninjatrader 8. If you can convert it to Ninjatrader 8 code, let me know how much to send to your paypal.



    [IntrabarOrderGeneration = false]
    Inputs:
    Sample_StartTime( 1230) ,
    Sample_EndTime (1231),
    Initial_Numshares(1),
    NumShares_Step (1),
    Max_Shares (5),
    Day_Profit_Target( 550 ),
    ExitIntraTrade(true),
    Price(close);

    Input:
    ____Show______ ("Show Items"),
    Show_HH_LL_of_SamplingTime (True),
    Show_EntryHigh_Entry_Low (True);


    vars:
    NP( 0 ),
    OPP( 0 ),
    PLB4Today( 0 ),
    ProfToday( 0 ),
    MP(0),
    tradeON(false),
    myTradePTgtPts(0),
    myDayPTarget(0),
    PriceLStick (0),
    NumShares(Initial_Numshares),
    LastProfitLoss(0),
    TT(0);

    TT = TotalTrades;

    LastProfitLoss = PositionProfit(1);

    MP = MarketPosition;
    NP = NetProfit ;
    OPP = OpenPositionProfit ;

    {**************************************
    Initialize at beginning of strategy
    **************************************}
    once begin

    {****************************************
    Multiply day profit target per contract
    by the number of contracts
    *****************************************}
    myDayPTarget = {NumShares *} Day_Profit_Target;
    end;

    {************************************************* *****
    Initialize at beginning of day (for day chart)
    NOTE: for 24 hour charts use "if date = Sample_StartTime ..."
    ************************************************** *****}


    {********************************************
    At end of every bar calculate today's profit
    *********************************************}
    ProfToday = OPP ; // Profit today

    {************************************************* *******
    Turn off entries when a day profit or loss target it hit
    ************************************************** *******}
    if ExitIntraTrade then begin
    {************************************************* *****
    Check profit and loss on every bar and exit intraTrade
    ************************************************** *****}
    if ProfToday >= myDayPTarget then begin
    tradeON = false;
    if MP = 1 then begin
    sell ("ProfitHit_LX") next bar at market;
    end
    else if MP = -1 then begin
    buyToCover ("ProfitHit_SX") next bar at market;
    end;
    end;



    end
    else begin
    {****************************************
    Check profit and loss only when flat
    *****************************************}
    If MP = 0 then begin
    if ProfToday >= myDayPTarget then begin
    tradeON = false;
    end ;
    end;
    end;
    Variables:
    HighVal( 999999 ) ,
    LowVal( 0 ) ;

    if Date <> Date[1] then
    begin
    HighVal = 0 ;
    LowVal = 999999 ;
    end ;

    if Time > Sample_StartTime and Time <= Sample_EndTime then
    begin
    // collect HH & LL during Smapling Time
    HighVal = MaxList( High , HighVal ) ;
    LowVal = MinList( Low, LowVal ) ;

    // plots
    If Show_HH_LL_of_SamplingTime then begin
    //HH
    Value1 = TL_new(d[1],t[1],HighVal,d,t,HighVal);
    TL_Setstyle(value1,5);
    TL_Setcolor(value1, darkcyan);
    TL_Setsize(value1,1);
    //LL
    Value2 = TL_new(d[1],t[1],LowVal,d,t,LowVal);
    TL_Setstyle(value2,5);
    TL_Setcolor(value2, darkmagenta);
    TL_Setsize(value2,1);
    end;

    If Show_EntryHigh_Entry_Low then begin
    //EH
    Value3 = TL_new(d[1],t[1],HighVal,d,t,HighVal);
    TL_Setstyle(value3,5);
    TL_Setcolor(value3, cyan);
    TL_Setsize(value3,1);
    //LL
    Value4 = TL_new(d[1],t[1],LowVal,d,t,LowVal);
    TL_Setstyle(value4,5);
    TL_Setcolor(value4, magenta);
    TL_Setsize(value4,1);
    end;

    end ;




    If Time > Sample_StartTime then begin
    PriceLStick = ((HighVal + LowVal)/2);

    If TT <>TT[1] then begin
    If LastProfitLoss >= 0 then NumShares = Initial_Numshares;
    If LastProfitLoss <0 then NumShares = NumShares * NumShares_Step;
    If NumShares >= Max_Shares then NumShares = Max_Shares;
    end;

    If NumShares > Initial_Numshares and LastProfitLoss > 0 then NumShares = Initial_Numshares;


    If Currentbar > 2 and Price crosses over PriceLStick then
    Buy ("PriceLSLong") NumShares shares next bar at market;


    If Currentbar > 2 and Price crosses under PriceLStick then
    Sell short ("PriceLSShort") NumShares shares next bar at market;

    end;

    #2
    Hello Kubera2024,

    Thank you for your support forum post and for your interest in NinjaTrader!

    You can search our extensive library of NinjaScript consultants who can convert code for you through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!

    This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
    Ryan L.NinjaTrader Customer Service

    Comment


      #3
      Its hard to out source unless the code is written out and not received in a file. A bad experience from a company that I ordered code from. A week later credit card numbers were being used internationally, the encrypted strategy truly didn't work. Since it didn't work, to troubleshoot, the overseas company wanted to have ability to access computer. Multiple attempts at trying to implement a product they freely sold on their site.

      So its better to pay for written code in a forum and safer.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by faustf, Today, 05:00 AM
      0 responses
      5 views
      0 likes
      Last Post faustf
      by faustf
       
      Started by NinjaCustomer, Today, 03:19 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by MarianApalaghiei, Today, 02:54 AM
      1 response
      5 views
      0 likes
      Last Post MarianApalaghiei  
      Started by RandanAL, Yesterday, 11:58 PM
      0 responses
      5 views
      0 likes
      Last Post RandanAL  
      Started by Kabua, Yesterday, 11:24 PM
      0 responses
      5 views
      0 likes
      Last Post Kabua
      by Kabua
       
      Working...
      X