Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple entries Problem

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

    Multiple entries Problem

    Hey guys, so this is my First Strategy that i'm trying to develop. Its super simple the Code is attached. I finally managed to get the strategy to use a Variable from an indicator, that's attached also. Problem is the strategy is Taking trades when it's Not supposed to.

    Pic 1: http://screencast.com/t/PQwUiY2teL
    Pic 2: http://screencast.com/t/a13M9REyyXJ

    a Long trade setup is: when Variable (in indicator, dgClimax = true cause Volume was high) this sets a BUY if Bar closed UP. vice versa for Shorts. but it's just entering trades at all times.

    I believe the problem might have to do with When the variable dgClimax is true or when it's false. I don't know. I'm completely lost

    Please help.
    Last edited by ginx10k; 02-12-2015, 02:32 PM.

    #2
    ginx10k, we will look into it and get back with our thoughts here shortly.

    Comment


      #3
      Hello,

      I took a look at the zip you provided, It looks like you may have just zipped the files together.

      I see that the strategy is looking for indicator names that are not included in the zip, maybe something is just not named right.

      Can you please do the following:
      Open a NinjaScript editor and compile to ensure everything is ok.
      Now go to File -> Utilities -> Export NinjaScript.
      Enter a File name
      Select both the strategy and the indicator and add them to the list on the right.
      Click Export and save the zip somewhere.

      After doing this please upload the new zip file. This will contain the correct items and everything should be named correctly so I can import the files and compile, currently I am getting compile errors and I am unable to import the scripts the way they are zipped.

      I look forward to being of further assistance.

      Comment


        #4
        Error

        I keep getting error when trying to Export it. it says compiling. but that doesn't make sense cause when I go to compile them both they do it just fine.

        and I don't see where the Error is. it says check my Log. but where.

        and why can't you just add the strategy file to Strategy folder, and indicator file to indicator folder, then compile. I'm just curious.

        Comment


          #5
          Hello,

          I did add them manually but received multiple errors on compile and figured this was a old version that was looking for missing references.
          I will take another look into it and see if I can see what is happening.

          Comment


            #6
            Nevermind. Just UPLOADED

            Sorry it was a File name error. I just uploaded the Exported Script
            Attached Files

            Comment


              #7
              Hello,

              Thank you for updating that, I was able to import this version.

              I will take a look at the script and write back shortly.

              Comment


                #8
                Hello,

                I took a look at the logic you are using for your entries and exits.

                It looks like based on the images and the way this runs it is taking too many positions at time.

                What I noticed is that you are using Exit and Enter statements in the same bar.

                I would like to ask, are you trying to exit the position and go to flat and wait or are you trying to reverse the position?

                If you are trying to reverse the position, it looks like these calls are all happening in the same bar not allowing the position to update. This means that unwanted positions can happen such as being 2 short or 2 long instead of always 1.

                To test this I commented out the Exit statements and no longer received the extra orders you have pictured.

                if you are not trying to reverse please let me know, in order to keep the exit orders you would need to add additional logic to ensure they happen after the position has been updated, otherwise if you are reversing you can remove the exits and allow the platform to exit for you when you call your Enter statement.

                I look forward to being of further assistance.

                Comment


                  #9
                  Okay. I appreciate the help. The thing is. I just want the Position to Close when a Bar Reverses. I don't want to enter New position (you are right about that).

                  So I thought when I place the statement
                  Code:
                  		if((Position.MarketPosition == MarketPosition.Long) && ((Close[1] < Close[3]) && (Close[1] < Close[2])) )
                  			{
                  				ExitLong("", "");
                  			}
                  that this was supposed to happen automatically. How do I set it to Close the position when my conditions are met. This is sort of my own "Trailing Stop" as in I want to stay in the trade Until this condition is met, instead of giving an actual Number to Trail by.

                  Comment


                    #10
                    Hello,

                    In this case you would want to modify the Enter logic by checking if the position is flat.
                    This will ensure that if you have a position, another position is not entered but the exit will still happen if you are in a position.

                    Here is a example of your EnterLong check.

                    Code:
                    if (Position.MarketPosition == MarketPosition.Flat && DG_HighVolumeScalper(5).BuySignal[0])
                    			{
                    You would need to check this for your EnterShort statement as well.

                    When I ran this I was only seeing 1 short or 1 long at any given time.

                    I look forward to being of further assistance.

                    Comment


                      #11
                      Late Exit

                      That gave me 1 position per signal. but problem it's Still Exiting Tooo Late. Picture shows what I mean. Cause I want if Long, and a Down Bar Closes, Immediately Exit Position.

                      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.



                      I changed the code to match what I'd like.
                      Code:
                      		if( FirstTickOfBar && (Position.MarketPosition == MarketPosition.Short) && (Close[1] > Open[1]) )
                      			{
                      				ExitShort("", "");
                      			}
                      But it still Exits 2 Up bars later. instead of right AFter the First Up Bar Closes

                      Comment


                        #12
                        Hello,

                        Based on the image, it looks like you are in the Strategy Analyzer is this correct?

                        If so a backtest will always use the Close of the bar, so in turn an order would show up on the next bar after the fact.
                        Even though you are using CalculateOnBarClose = false, this will still be the same in the backtest.

                        For the backtest to look similar to a live chart, the script would need to incorporate intrabar granularity and run logic using the BarsInProgress index.

                        Did you try this on a chart rather than backtest to see if the results look more correct?

                        I look forward to being of further assistance.

                        Comment


                          #13
                          That solved that problem. So for now I'm good. only one last thing I'm trying to do. if I can't figure it out I'll mention it here.

                          you have been awesome. thank you so much for your help

                          Comment


                            #14
                            Quantities problem

                            Okay. I have one more Topic. I have my orders set at 1. I'm this means like 10 cents per pip for FOREX. but my strategy analyzer is giving me weird numbers: http://screencast.com/t/GAnpdS2w

                            How's this possible. I haven't actually traded Ninja live yet. going to it Monday. so I'm wondering if trading FOREX and I want to simulate a $500 account. do I have to change my Quantities to something larger? do I have to change something to make the orders seem like a LIVE account with FXCM margin.

                            Comment


                              #15
                              Hello,

                              Yes you would need to change the default quantity to what you want.

                              In the strategy properties, look for "Set Order Quantity"

                              You can choose a pre defined value by using "By Default Quantity"

                              The default is 1 which would not be the amount you are looking for in forex, you would need to enter the total amount you want to trade per 1 entry.





                              Otherwise you can choose "By Account Size" to use an account size which would be used for calculating the amount.





                              I look forward to being of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              656 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              371 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              579 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X