Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Open and Low prints the same value

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

    Open and Low prints the same value

    Hi
    i have astrategy and when i use prints it prints open[0] and low[0] the same value, when its not. What would it be?
    these are my prints
    Print("Current Open 0 :"+Open[0] );
    Print("Current Low 0 :"+Low[0] );​

    how can I call Low[0]?
    Click image for larger version  Name:	image.png Views:	0 Size:	1.13 MB ID:	1246026
    Last edited by tkaboris; 04-13-2023, 09:53 AM.

    #2
    Hello tkaboris,

    That would happen if you are printing on the first tick of the bar. I otherwise wouldn't be able to tell based on the screenshot. I would suggest to make a new empty script without any conditions or logic and just add prints to see if you get the same result.

    Comment


      #3
      Yes, thats right i use first tick of bars .

      Is there a way to call "Low of the current bar?" with firsttickofbars? if so how?

      Comment


        #4
        Hello tkaboris,

        That is what you are already doing, on the first tick of the bar the low is the same as the open and the same as the high and close, there has been no price movement at that point for the values to be different. High and Low prices are updated as more ticks come in that are either higher or lower than the existing high/low prices. You would need to print after the first tick of the bar if you wanted to see different values. You can reference the previous bars high/low if you wanted by using 1 bars ago.

        Comment


          #5
          If you look at screenshot in databox low is 13053.50 but when i print Low[0], it prints as 13055. If i change to Low[1] it accurately prints low of previous bar. I was just wondering if there is a special code dealing with isfirsttickofbar orsomething is wrong with the strategy...

          Comment


            #6
            Hello tkaboris,

            The databox is looking at the most recent bar information after the first tick, that's the current up to date values. If your script is using OnEachTick and you have a condition for IsFirstTickOfBar then you are not looking at the up to date bar info, you are looking at the first tick only.

            What you are asking about is looking into the future on the first tick of the bar which is not possible, that data has not occured yet when your script hits IstFirstTickOfBar. For the bar to have different values more ticks need to come in after the first tick to build the bar. If you want the current bar info you need to stop using IsFirstTickOfBar for the print so you can print the building bar information as each new tick calls OnBarUpdate.

            Comment


              #7
              I see, I am making a pinbar strategy and
              I am using onpricechange but wanted to make sure to open position when bar closes with my condition.
              if I switch to onbarclose then my trailing seems not working and losses orders...
              Whats the solution would be for pinbar strategy?

              Comment


                #8
                Hello tkaboris,

                I dont know what a pinbar strategy is to answer that type of question.

                If you want to open a position when a bar closes you would either need to use OnBarClose or you would need to submit the order on the first tick of the following bar, the first tick of the bar is the tich which closes the previous bar.

                Trailing stops submitted with SetTrailStop are updated based on the Calculate setting. If you use OnBarClose trailing will happen once per bar.

                To keep the trailing order updating on price changes you would need to submit your entry on the first tick of the bar. If you use SetTrailStop that will allow the trailing to happen on each price change. If you are doing your own trailing that logic would need to be done from OnBarUpdate for every price change and not just within the IsFirstTickOfBar condition. Your prints would also need to go outside of the IsFirstTickOfBar condition so you can see the updated prices as the bar builds.

                A simple example would be:

                Code:
                if(IsFirstTickOfBar)
                {
                    // entry logic, submit initial trailing stop
                } else {
                    Print("Current Open 0 :"+Open[0] );
                    Print("Current Low 0 :"+Low[0] );​
                    //update trailing stop if you are using something other than SetTrailStop​
                }

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                66 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                141 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                46 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