Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bool declarations

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

    #16
    Hello galsermil,

    Thank you for your reply.

    The prints would show in the NinjaScript Output window along with your Print() statements.

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

    Comment


      #17
      kATE,

      tHIS IS NUTS. MY BOOLS STILL FLIPPED when I made the change that you suggested so I commented out Sets 1 and 2 and and they did not flip. Just to ensure I was past the number of Bars required to trade I changed the number to return to 25 then 3 pair did not flip and 1 did. Got anymore suggestions.?

      Comment


        #18
        Kate,

        4 pair have been running now for several hours with enabled strategies.and as earlier, 3 are showing correct bool and 1 is still flipped. Also there has not been a single Trace entry of any kind. Does that tell us anything?

        Comment


          #19
          Hello galsermil,

          Thank you for your replies.

          After you've made the change and turned on TraceOrders, have you completely removed and re-added the strategy to a chart so all the changes are recognized? If you don't remove and re-add the strategy to the chart, changes made in OnStateChange will generally not be reflected, so you wouldn't see the traces.

          Thanks in advance; I look forward to assisting you further.

          Comment


            #20
            I did exactly that.

            Comment


              #21
              Kate,

              It is possible that this is what you were saying and I did not understand it but by a sheer fluke I discovered that the processing of historical data is what kept changing my bool variable from false to true and would not allow any trades to be taken. I call it a fluke because for some reason the chart background started turning green which was the prescribed color when the first trade was open. The fluke is because I could not reproduce it. My next pursuit was to try to prevent the historical data from changing the bool value so I inserted state ==state.historical, return, in 'OnBarUpdate'. You did something like this in one of my previous projects but unfortunately I can't locate it to see exactly what you did. My NT8 got corrupted and I had to replace it and I lost a lot of data. but as far as I can tell the bool change stopped but also nothing else happens. I am attaching a current copy of my <,cs> file so I am hoping that you will look at it and see if you can Identify why my script will not continue and take trades, One other item in the script that I have concerns with is determining the P&L position of a single trade. I am not sure what I am using does that or if it determines P&L for all trades. Determining the P&L for Trade#1 is relevant because it is needed for Exit purposes and knowing when to take a second trade. I am using it to determine the Exit rather than use 'Profit Target' so that I can change the bools at the same time to allow additional trades to be taken.

              Please note that this script is different from the previous one because the previous conditions for a trade were a temporary substitute for what is now coded in which is an indicator created by the person that wrote the code for the Divergence Indicator. I have the source code for the RSI_Div indicator but I do not have the source code for IndicatorDivergence102. I have removed the dozen or so <print> statements which I have been using to try to locate my problem,. Any other suggestions that you have to improve the script would be very much appreciated.

              Attached Files

              Comment


                #22
                Hello galsermil,

                Thank you for your reply.

                A note here that I would suggest checking back over your logic to ensure you're setting bools back to false when exiting trades. For example, I see you're trying to exit a first trade here but are setting the FirstTradeOpen bool to true and not false:

                if((Close[0] - FirstEntryClose) >= Target) //Use this rather than Set Profit so First_Trade_Open can be set to closed( false)
                {
                ExitLong();
                FirstTradeOpen = true;
                }

                It looks like you may have incorrect logic for switching bools like this in more than one place. Make sure you're setting them to true when an order is placed, and to false when you exit that order.

                Further, restricting processing to real time only would require this logic:

                if (State == State.Historical)
                return;

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

                Comment


                  #23
                  Kate,

                  I had caught those bool mistakes before you got back to me so that is okay. Will you tell me a better way to calculate P&L for an open trade. There will be times when I have two trades open and will need to calculate P&L for just one of them. Thank you.

                  Comment


                    #24
                    Hello galsermil,

                    Thank you for your reply.

                    You can't really calculate the performance of an open position separately by entry short of calculating that yourself based on the current price, the entry quantity and the entry price that quantity was entered at. Position.GetUnrealizedProfitLoss would get you the current unrealized PnL for the entire position quantity regardless of whether you've scaled in.

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

                    Comment


                      #25
                      Kate, thank you.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Yesterday, 05:17 AM
                      0 responses
                      72 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      143 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      76 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      47 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      51 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X