Announcement

Collapse
No announcement yet.

price entry exit

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

  • price entry exit

    does anybody know if it is possible to run a formulas efs on price only, so that the buy/sell signals would be generated if price hit a certain figure.

    example: using dow jones

    if price hits 9500 (+10) go long/ if it hits 9500 (-10) stoped out & if it hit 9600 (-30) close long

    the (+10) (-10) & (-30) would be changeable parameters

    and the same for 9600/9700/9800/9900/10000/ and so on,


    if you know what i mean,

  • #2
    shogun
    Yes it is possible to set the condition for buy/sell to be a defined price (ie like in the examples you mention)
    Alex

    Comment


    • #3
      thanks alix,

      do you or anybody else know if there are any examples in the efs bulletin boards of how the javascript formulas might look, i have been looking but seem to have drawn a blank,

      would i define price as close()

      and how would i define the entry/exit numbers, 9500 (+10)


      all help is much appreaciated

      Comment


      • #4
        shogun
        Enclosed is a very basic example of how it could be done. The entry price is defined in Edit Studies together with the profit and stop levels.
        In the chart below you see the results. The green background highlights the bars in which the strategy is long, the red background when the strategy is stopped out and the blue when it sells for profit.
        Again this is only an example
        Alex

        PHP Code:
        function preMain(){
        setPriceStudy(true);

            var 
        fp1 = new FunctionParameter("Price"FunctionParameter.NUMBER);
            
        fp1.setDefault(10500.00); 
            
            var 
        fp2 = new FunctionParameter("Margin"FunctionParameter.NUMBER);
            
        fp2.setDefault(5.00); 
            
            var 
        fp3 = new FunctionParameter("Profit"FunctionParameter.NUMBER);
            
        fp3.setDefault(10.00); 
            
            var 
        fp4 = new FunctionParameter("Stop"FunctionParameter.NUMBER);
            
        fp4.setDefault(10.00); 

        }

        function 
        main(Price,Margin,Profit,Stop){

            if(
        Strategy.isLong()==false&&formatPriceNumber(close())>=Price+Margin){
                
        Strategy.doLong("Long",Strategy.LIMIT,Strategy.THISBAR,null,Price+Margin);
            }
            if(
        Strategy.isLong()==true&&formatPriceNumber(close())<=Price-Stop){
                
        Strategy.doSell("Stop",Strategy.STOP,Strategy.THISBAR,null,Price-Stop);
                
        setBarBgColor(Color.red);        
            }
            if(
        Strategy.isLong()==true&&formatPriceNumber(close())>=Price+Profit){
                
        Strategy.doSell("Profit",Strategy.STOP,Strategy.THISBAR,null,Price+Profit);
                
        setBarBgColor(Color.blue);
            }
            if(
        Strategy.isLong()==true){
               
        setBarBgColor(Color.lime)
            }

        return;

        Comment


        • #5
          alex many thanks

          i am quite new to efs formulas and using javascript (and it is not easy ) i have found many examples using ma/macd/rsi etc but no examples which use just price movement as a entry/exit,
          so your example is a big help for me,

          Comment


          • #6
            shogun
            You may also want to search through Brad Matheny's messages (user name Doji3333) as he has posted various examples of entries on Limit or Stop prices
            Hope this helps
            Alex

            Comment


            • #7
              ok will do

              thanks,

              Comment

              Working...
              X