Announcement

Collapse
No announcement yet.

Recording Entry Price

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

  • Recording Entry Price

    How would you write the code to record your entry price for use with profit targets, stops, and trailing stops?

  • #2
    czumwalt
    What you would do is create a variable called for example EntryPrice and then where you set the doLong/doShort entry command you would also set the EntryPrice for the same value(s).
    Then you can use the EntryPrice variable to set stops and/or targets.
    A very clear example of this is visible in this thread in JasonK's EFS.
    Hope this helps
    Alex

    Comment


    • #3
      Ok. Ive got my profit targets working but how do i keep the system from reentering immediatly after the target is reached. After the target has been reached i want to not enter anymore trades until the next day. Is this possible?

      Comment


      • #4
        czumwalt
        The first thing that comes to mind is to create a variable, called TradeFlag for example, that is normally set to 0 but gets switched to 1 once in a trade.
        Then you can reset it to 0 at the end of the current session or beginning of the next one.
        Alex

        Comment


        • #5
          yes. This is what i have been trying but whenever I add this variable the it stays out of trades completely. I am not very good at coding.

          What i was doing was putting a variable at the top called vTargetHit. Whenever a profit target was hit i would enter a line under the trade like this

          vTargetHit = 1;

          then i would have a line in the code such as
          When time of Day = 9:30 then vTargetHit = 0 (to reset at begining of the day)

          as a trade condition the variable vTargetHit had to = 0 before we could enter a trade.

          When i did all this it kept me out of trades completely.

          Any help would be greatly appreciated.

          Comment


          • #6
            This is correct...

            Although on important function is missing. You have to turn back on the TradeFlag variable for the next day of trading.

            I use time variables to do this for backtesting purposes. like...

            PHP Code:
            var vHour;
            var 
            vMin;
            var 
            vTime = new Date();
            //---------------------------------------------------
            //  Get Time Variables 
              
            vTime getValue("Time"0);
              
            vHour vTime.getHours();
              
            vMin vTime.getMinutes();

            var 
            StartHour 6;
            var 
            StartMinute 30;

            if (
            vHour == StartHour) && (vMin StartMinute)) {
              
            TradeFlag true;  // or ZERO

            This will set your "TradeFlag" trigger ON before the market opens (@ 6:30), then your existing entry code will allow it to trade.

            You could also use a similar function to allow trading between certain times.... Like this..

            PHP Code:
            //  Trade Time Limit Variables
            var vStartHour 6;
            var 
            vStartMin 30;
            var 
            vEndHour 7;
            var 
            vEndMin 30;
            // TradeFlag Reset Time
            var StartHour 6;
            var 
            StartMinute 30;

            var 
            vHour;
            var 
            vMin;
            var 
            vTime = new Date();
            //---------------------------------------------------
            //  Get Time Variables 
              
            vTime getValue("Time"0);
              
            vHour vTime.getHours();
              
            vMin vTime.getMinutes();

            if (
            vHour == StartHour) && (vMin StartMinute)) {
              
            TradeFlag true;  // or ZERO
            }

             if (((
            vHour vStartHour) && (vHour vEndHour)) || ((vHour == vStartHour) && (vMin >= vStartMin)) || ((vHour == vEndHour) && (vMin <= vEndMin)) ) {  //Within time restrictions

              
            if (TradeFlag == true) {
                
            Trade Away..
              }

             } 

            Hope this helps..

            Brad
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment

            Working...
            X