Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Barsinprogress issue

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

    #16
    Hello tkaboris,

    You need to use prints if the logic is not working as you expected it to. I can't tell what the script is going to do just by looking at the code, you would have to output what its doing and then make any adjustments needed to make it work the way you actually wanted. You have multiple variables being used and price conditions, you likely will need to output those details so you can better understand whats happening.

    It also looks like you are setting up the variables in OnStateChange for your indicators. Not all indicators support multi timeframes, you may need to just call the indicator directly inside the BarsInProgress condition to make sure you get a value based on the secondary series.


    Code:
    else if(BarsInProgress == 2)
    {
    double indicatorValue = TrendMagicModified(Params).BullOrBear[1] ;

    Comment


      #17
      HI I have added prints and i got true/false fluctuating on each tick even though the line is consitently bear.
      Also i have indicators in state.confiture not onstatechange
      Print("htfbull true:"+HTFBull);

      else if(BarsInProgress == 2)
      {
      // double indicatorValue = TrendMagicModified(Closes[1], 20, 14, 1, false);
      TrendMagicModified2 = TrendMagicModified(Closes[1], 20, 14, 1, false);
      // Print("TrendMagicModified1.BullOrBear[0]"+TrendMagicModified1.BullOrBear[0]);
      // Print("TrendMagicModified2.BullOrBear[0]"+TrendMagicModified2.BullOrBear[0]);
      if (TrendMagicModified2.BullOrBear[1] == 0)
      {
      HTFBull = true;
      }
      else
      {
      HTFBull = false;
      }
      if (TrendMagicModified2.BullOrBear[1] == 1)
      {
      HTFBear = true;
      }
      else
      {
      HTFBear = false;
      }
      Print("htfbull true:"+HTFBull);

      }​

      Comment


        #18
        Hello tkaboris,

        You would have to continue debugging the script if its not working as expected. As mentioned I can't just look at the code to know whats wrong if its not logically working right. You will need to explore the code and add relevant prints to see what may be causing that outcome.

        State.Configure is part of OnStateChange, OnStateChange is the overall override which states are used from.

        If you have your indicators in OnStateChange they may or may not work with input, you would have to look at the indicators code to know if that use case would work or not. If you are unsure your indicator should go inside the BarsInProgress like the code you provided. You don't need to specify the input for that use:

        Code:
        else if(BarsInProgress == 2)
        {
        TrendMagicModifiedIndi = TrendMagicModified(20, 14, 1, false);

        Comment


          #19
          Thank you that changed it. I am evaluating the logic again.


          Can you also look at my other issue with sar indicator
          Hi I want to set initial stopprice to a Swing Low value for longs. And then as usual. In other words have an additional initial requirement, where first CurrentLongStopPrice is set to SwingLow value and then CurrentLongStopPrice is set to LongTrailStopDistance once price trigggers CurrentLongTriggerPrice. Is it possible?

          Comment


            #20
            HI i now have executions on secondary series instead of primary.

            I only triggered EntryLong() once in primary series. What can i do?


            Click image for larger version

Name:	image.png
Views:	115
Size:	1.35 MB
ID:	1260469

            Comment


              #21
              Hello tkaboris,

              The picture you provided has the same instrument in both charts, you should be able to see strategy trades if you have chart trader open in the other chart with the same account selected. To know if you are placing trades to the secondary series would require looking through your logic and making sure that all entries are only happening for the primary or being submitted to the primary bars in progress.

              Comment


                #22
                HI It seems like my order updates are seperated.

                after barsingprogress2

                its my trail stop and trail stop is in onmarketData section. can I again place


                if (BarsInProgress == 0)
                {​
                protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
                {
                if (marketDataUpdate.MarketDataType == MarketDataType.Last)
                {​

                my current trail function
                }

                Comment


                  #23
                  or its just better to move trail function inside onbarupdate?

                  Comment


                    #24
                    Hello tkaboris,

                    You would need to form a more specific question here, I am not sure what you are asking or trying to explain.

                    Comment


                      #25
                      Sorry about that.
                      last question so currently my exitlongstopmarket(bars in progress is set to 1)
                      my primary dataseries
                      mybsecindary 1tick
                      my third is 1000ticks.

                      If I want to enter on primary I need to set bars in progress to 0. Right. Will one Rick data still be in effect for quality backtesting purposes?

                      ExitLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)

                      Comment


                        #26
                        Hello tkaboris,

                        If you want to specify the series for backtesting purposes yes you need to enter the order either from the BarsInProgress you wanted it on or the most granular BarsInProgress for high fill order processing.

                        Setting the orders BarsInProgress will effect how it fills. You can fill based on the primary bars or the secondary bars assuming they are more granular. You would see differences in prices for fills if you use a more granular series.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by NullPointStrategies, 03-13-2026, 05:17 AM
                        0 responses
                        86 views
                        0 likes
                        Last Post NullPointStrategies  
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        151 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        79 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        52 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        59 views
                        0 likes
                        Last Post TheRealMorford  
                        Working...
                        X