Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

making changes for currency trading

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

    making changes for currency trading

    hi, i have below line for regular MNQ strategy.
    triskToSarTicks = Math.Abs(Close[1] - ParabolicSAR1[1]) / TickSize;
    trr1to1Long = triskToSarTicks * 1;

    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to1Long), "PTL", "TML");

    now i want to switch to pips and i am confused about TickSize part.
    How would I appropriately rewrite this logic for pips calculation?
    Thank you

    #2
    Hello tkaboris,

    Thank you for your post.

    The TickSize value comes from the Master Instrument properties that are saved in the Control Center > Tools > Instruments window. Tick size is described in the help guide as "the increment value the instrument trades in" and, generally, TickSize is also the equivalent of one pip. These terms are sometimes used interchangeably, as they both represent the smallest price change for an instrument. You may always verify that the TickSize for a forex instrument is set to the desired value for specific instruments from the Instruments window, or you could even test a strategy and print out the value of TickSize to ensure it is behaving as expected.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Well with current code my strategy sets take profit (limit) 100 pips from entry, no matter what I do. on 6B.
      I printed trr1to1Long equals to only 38 pips but it sets limit to 100. I cant figure out what is going on..

      ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to1Long), "PTL", "TML");

      Comment


        #4
        Hello tkaboris,

        Thank you for your reply.

        Are you also potentially using SetProfitTarget() in your script? If you use SetProfitTarget() and an Exit() method for the same position, one of those order methods will be ignored due to the internal order handling rules that the managed approach follows. I suggest printing the Position.AveragePrice, the TickSize, and trr1to1Long just before submitting your ExitLongLimit() to double-check the values being used. You may also verify that the signalName for the order in place is PTL and not a different order instead. TraceOrders is also a helpful tool to understand which orders are being submitted:


        If you do not understand the price where your order is being placed, please provide the output of your prints for each of the previously mentioned values and I would be glad to take a look at that with you and identify the next steps for debugging.

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

        Comment


          #5

          hi I placed those 3 just before my limit order and i get these
          Its for 6B. It placecs take profit to 100 instead of ration one to one. So in this case tp was suppose to be 25 pips not 100 pips

          Entering Trend Magic Long: 7/27/2023 3:10:00 AM- 1212
          Value:1.29610466347944
          longRiskToSarTicks25.5199999999989
          htfbull true:False
          TrendTradeLong:True
          Position.AveragePrice1.2967
          StopTicksLong * TickSize0.004

          Position.AveragePrice:1.2967
          TickSize:0.0001
          trr1to1Long:25.5199999999989​

          Comment


            #6
            Hello tkaboris,

            Thank you for your reply.

            What is the output from Trace Orders when you enable it in State.SetDefaults and monitor the output when the take profit is submitted?

            I look forward to your reply.

            Comment


              #7
              i got these values
              ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to1Long), "PTL", "TML");
              ===============================
              Entering Trend Magic Long: 7/26/2023 10:15:00 AM- 1022
              Trend Magic Value:1.29160099630957
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=Submitted instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.291 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=Accepted instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.291 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=Submitted instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.2942 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=Accepted instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.2942 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=Working instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.2942 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=ChangePending instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.291 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=ChangeSubmitted instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.2911 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=Accepted instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.2911 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              Position.AveragePrice: 1.2926
              TickSize: 0.0001
              trr1to1Long: 15.8144000000005
              onetoone: True
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=ChangePending instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.2942 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=ChangeSubmitted instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.3026 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=Accepted instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.3026 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='9954154f76f047b0aca6a33861c4450e' account='Playback101' name='PTL' orderState=Working instrument='6B 09-23' orderAction=Sell orderType='Limit' limitPrice=1.3026 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286826 time='2023-07-26 10:15:03' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=ChangePending instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.2911 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:20:02' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=ChangeSubmitted instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.2912 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:20:02' gtd='2099-12-01' statementDate='2023-07-26'
              orderId='3aa940fc6d104d40a6194151f890f555' account='Playback101' name='SLL' orderState=Accepted instrument='6B 09-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1.2912 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=286825 time='2023-07-26 10:20:02' gtd='2099-12-01' statementDate='2023-07-26'


              Click image for larger version  Name:	image.png Views:	0 Size:	422.0 KB ID:	1262857​​
              Attached Files
              Last edited by tkaboris; 08-02-2023, 04:43 PM.

              Comment


                #8
                I see that it first sets the one to one ratio take profit ok but then strategy changes it. I atrach code for riskreward that i use.

                Code:
                if (Position.MarketPosition == MarketPosition.Long && myFreeTradeLongTrail == true && switchtrail == true)
                                        {
                //                            ExitLongStopMarket(1, true, Position.Quantity, MySarStopL, "SLL", "TML");
                //                            ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * TrailTakeProfit), "PTL", "TML");
                                            if(UseRiskReward)
                                            {
                                            if(onetoone){
                                                Print("Position.AveragePrice: "+Position.AveragePrice);
                                                Print("TickSize: "+TickSize);
                                                Print("trr1to1Long: "+trr1to1Long);
                                                Print("onetoone: "+onetoone);
                
                                                ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to1Long), "PTL", "TML");
                                            }                                                                                
                                            if(onetoonehalf){                                                                
                                                ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to15Long), "PTL", "TML");
                                            }                                                                                
                                            if (onetotwo){                                                                    
                                                ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to2Long), "PTL", "TML");
                                            }                                                                                
                                            if (onetotwohalf){                                                                
                                                ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to25Long), "PTL", "TML");
                                            }                                                                                
                                            if (onetothree){                                                                  
                                                ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to3Long), "PTL", "TML");
                                            }
                                            else
                                                ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * TrailTakeProfit), "PTL", "TML");
                                            }
                                            switchtrail =false;
                
                                        }    ​

                Comment


                  #9
                  NinjaTrader_Emily said
                  Tick size is described in the help guide as "the increment value the instrument trades in" and, generally, TickSize is also the equivalent of one pip. These terms are sometimes used interchangeably, as they both represent the smallest price change for an instrument.
                  Actually, that's not correct. TickSize is the smallest price increment of any Instrument. In Forex, that is as true as for any other Instrument. However, in Forex One PIP is equal to 10 Ticks. They are most definitely not the same. That is why Forex traders easily talk about "half a pip", which would be impossible if a PIP were the smallest increment and equivalent to a Tick. In this case, saying "half a pip" means exactly 5 Ticks. If the Forex TickSize is 0.00001, the size of One PIP is 10x 0.00001 = 0.0001. For a JPY pair, it is a little different. TickSize is 0.001, and One PIP for a JPY pair is 0.01. Sometimes, Forex traders use the term "pipette" interchangeably with a Tick in Forex pairs. In NinjaTrader 7, the term used is "Tenth Pip".

                  Thanks.
                  Multi-Dimensional Managed Trading
                  jeronymite
                  NinjaTrader Ecosystem Vendor - Mizpah Software

                  Comment


                    #10
                    Hello tkaboris,

                    Thank you for your reply.

                    I suggest adding additional print statements to understand how the exit price is being calculated based on which exit criteria is being met. Here is an example of prints you could add:

                    Code:
                    if (Position.MarketPosition == MarketPosition.Long && myFreeTradeLongTrail == true && switchtrail == true)
                    {
                    // ExitLongStopMarket(1, true, Position.Quantity, MySarStopL, "SLL", "TML");
                    // ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * TrailTakeProfit), "PTL", "TML");
                    Print(string.Format("{0} ExitLongLimit submitted.  Position.AveragePrice: {1} TickSize: {2}, TrailTakeProfit: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, TrailTakeProfit, (Position.AveragePrice + (TickSize * TrailTakeProfit))));
                    if(UseRiskReward)
                    {
                    if(onetoone){
                    Print("Position.AveragePrice: "+Position.AveragePrice);
                    Print("TickSize: "+TickSize);
                    Print("trr1to1Long: "+trr1to1Long);
                    Print("onetoone: "+onetoone);
                    
                    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to1Long), "PTL", "TML");
                    Print(string.Format("{0} onetoone exit submitted.  Position.AveragePrice: {1} TickSize: {2}, trr1to1Long: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, trr1to1Long, (Position.AveragePrice + (TickSize * trr1to1Long))));
                    }
                    if(onetoonehalf){
                    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to15Long), "PTL", "TML");
                    Print(string.Format("{0} onetoone exit submitted.  Position.AveragePrice: {1} TickSize: {2}, trr1to15Long: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, trr1to15Long, (Position.AveragePrice + (TickSize * trr1to15Long))));
                    }
                    if (onetotwo){
                    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to2Long), "PTL", "TML");
                    ​​​​​​​Print(string.Format("{0} onetotwo exit submitted.  Position.AveragePrice: {1} TickSize: {2}, trr1to2Long: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, trr1to2Long, (Position.AveragePrice + (TickSize * trr1to2Long))));
                    }
                    if (onetotwohalf){
                    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to25Long), "PTL", "TML");
                    ​​​​​​​​​​​​​​Print(string.Format("{0} onetotwohalf exit submitted.  Position.AveragePrice: {1} TickSize: {2}, trr1to25Long: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, trr1to25Long, (Position.AveragePrice + (TickSize * trr1to25Long))));
                    }
                    if (onetothree){
                    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * trr1to3Long), "PTL", "TML");
                    ​​​​​​​​​​​​​​​​​​​​​Print(string.Format("{0} onetothree exit submitted.  Position.AveragePrice: {1} TickSize: {2}, trr1to3Long: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, trr1to3Long, (Position.AveragePrice + (TickSize * trr1to3Long))));
                    }
                    else
                    ExitLongLimit(1, true, Position.Quantity, Position.AveragePrice + (TickSize * TrailTakeProfit), "PTL", "TML");
                    ​​​​​​​​​​​​​​​​​​​​​​​​​​​​Print(string.Format("{0} ExitLongLimit submitted.  Position.AveragePrice: {1} TickSize: {2}, TrailTakeProfit: {3} limit price: {4}", Time[0], Position.AveragePrice, TickSize, TrailTakeProfit, (Position.AveragePrice + (TickSize * TrailTakeProfit))));
                    }
                    switchtrail =false;
                    
                    }​
                    Please let me know if I may be of further assistance.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Today, 05:17 AM
                    0 responses
                    52 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    130 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    70 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    43 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    47 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X