Announcement

Collapse
No announcement yet.

Values stored in variables

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

  • Values stored in variables

    Hello,

    Within an EFS, if i record the EntryPrice by writing the following code:

    If Condition1 = true then
    {
    Buy 1 contract at Market;
    Entry_price=Close[0];
    };

    Note that the above code is like Easylanguage in TradeStation (where Close[0] is the current price), i assume that the same can be done in EFS language? My question is if I run the above code, will EFS remember the exact entry price recorded in the Entry_Price variable if my computer is switched on and then off over the weekend? or instead will the variable only show a Open, High, Low or Close value and not the exact entry price which took place in the past, say 10 daily bars ago?

    My next question is: within EFS how do I call the "number of bars elapsed since entry date"?

    Also, another question, in EFS can I somehow call the current "marketPosition" ie 1 for long, 0 for flat and -1 for short?

    My final question is: Can I run EFS strategies on "continuous contracts" like on symbol R 1!-EIR to do "both" backtesting and also live automated trading in real-time?

    I used to use tradestation and other plaforms for many years, but now have to switch to e-signal as e-signal allows me to trade many more international markets, like Canadian and aussie bonds for example. Just need to try and work out first if i can do what i need to do in e-signal. I'm also using NinjaTrader to send trade signals from tradestation and e-signal to my broker, if anyone is interested in this type of set-up, i hope my questions can help someone else too.

    Thanks in advance. Any help would be very much appreciated.

    Regards

    Rod
    Last edited by Rocket130713; 08-15-2008, 06:18 AM.

  • #2
    Re: How to call "Entry_Price" and "Number of bars since Entry" ?

    Rod

    My question is if I run the above code, will EFS remember the exact entry price recorded in the Entry_Price variable if my computer is switched on and then off over the weekend?
    While it is loading an efs will run through all the historical bars executing once on each bar using only the values of the completed bars. So if you need to store a specific intrabar price you need to save it to a file using the File Object (see the EFS KnowledgeBase for the description and syntax of this object and its methods). Also try searching the forums as this topic has been covered before

    My next question is: within EFS how do I call the "number of bars elapsed since entry date"?
    You can do that with a bar counter routine (see the example that I provided to you in another thread) or you can assign to a global variable the value returned by getCurrentBarCount() at the time of entry and then determine the number of bars elapsed by subtracting that from the current bar count.

    Also, another question, in EFS can I somehow call the current "marketPosition" ie 1 for long, 0 for flat and -1 for short?
    In back testing you would use the Strategy.isLong() or Strategy.isShort() methods of the Strategy Object. For trading purposes you would need to set up your own variables and logic to track the status of your position
    Alex

    Comment


    • #3
      thanks Alexis. Really appreciate your help. You are certainly a wizard when it comes to computers and e-signal.

      Comment


      • #4
        Rod
        You are most welcome and thank you for the compliment
        Alex


        Originally posted by Rocket130713
        thanks Alexis. Really appreciate your help. You are certainly a wizard when it comes to computers and e-signal.

        Comment


        • #5
          Last edited by Rocket130713; 08-20-2008, 11:00 PM.

          Comment


          • #6
            heres a quick example on how you can use a variable (LastEntryPrice in this case) to simply place tags on your chart to show the profit or loss of the last trade (the parameters of trading this program is a simple price cross of a 20 sma).. however, as Alexis said, this only works if you are using the close price of each bar, if you wish to use a price value within the bar somewhere, it would take significantly more programming, or the values must be obtained while the market is open rather than during testing of historical bars. if that is what you wish to do, you need to record the values into a text doccument, as Alexis said.
            PHP Code:
            var LastEntryPrice 0;
            var 
            LastTradeResult 0;
            var 
            0;

            function 
            preMain() {
                
            setColorPriceBars(true);
                
            setPriceStudy(true);
                
            setStudyTitle("20 SMA Cross");
                
            setCursorLabelName("20 SMA"0);
                
            setCursorLabelName("Status"1);

            }

            function 
            main() {

                
            LastTradeResult close() - LastEntryPrice

                
            if (close() > sma(20) && != "Long") {
                    
            Strategy.doLong(""Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT, 0)
                    
            drawTextRelative(0close(), LastTradeResult.toFixed(2)*-1Color.RGB(255,255,255), Color.RGB(0,0,0), Text.LEFT"Arial"9)
                    
            LastEntryPrice close()
                    
            "Long"
                
            }

                if (
            close() < sma(20) && != "Short") {
                    
            Strategy.doShort(""Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT, 0)
                    
            drawTextRelative(0close(), LastTradeResult.toFixed(2), Color.RGB(255,255,255), Color.RGB(0,0,0), Text.LEFT"Arial"9)
                    
            LastEntryPrice close()
                    
            "Short"
                
            }

                
            setPriceBarColor(Color.RGB(128,128,128))
                if(
            == "Long"setPriceBarColor(Color.RGB(0,255,0))
                if(
            == "Short"setPriceBarColor(Color.RGB(255,0,0))

                return new Array (
                    
            sma(20),
                    
            v
                
            )


            Last edited by kalzenith; 08-21-2008, 09:25 AM.

            Comment

            Working...
            X