Announcement

Collapse
No announcement yet.

can someone explain this code

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

  • can someone explain this code

    Hi Everybody, is there anybody that can translate this easylanguage ? I want to build it in EFS, but I have no idea about EasyLanguage.

    If somebody can tell me the logic of what is going on below, I will happily code it and put it on here.

    Thanks

    Variables:
    VQI(0),
    SumVQI(0);

    If TrueRange <> 0 and (High - Low) <> 0 Then
    VQI = ((Close - Close[1]) / TrueRange + (Close - Open) / (High - Low)) * 0.5
    Else
    VQI=VQI[1];
    VQI = AbsValue(VQI) * ((Close - Close[1] + (Close - Open)) * 0.5);
    SumVQI = SumVQI + VQI;
    Plot1(SumVQI,"");
    Plot2(Average(SumVQI,9),"");
    Plot3(Average(SumVQI,200),"");

  • #2
    Re: EasyLanguage

    Hello, I've been looking at Easylanguage over the last year, tradestation is pretty good, but I want to learn eSignal too. This was in ActiveTrader mag wasnt it? Aug 2002 For "The good, the bad and the volatility" by Thomas Stridsman. Basically TS timeseries data is an array datatype so any reference to Close[1] means "close 1 period ago". The current period is close[0] but in TS the brackets are omitted so its the same as just "close". It looks for the good volatility, i.e. when volatility is trending. I bet this would be excellent for any volatile stocks.



    Variables:
    VQI(0), // volatility quality index
    SumVQI(0); //sum of volatility indicator

    //Volatility Quality Index by Thomas Stridsman
    //True range is the greatest of H-L,Ref(C,-1)-H, or Ref(C,-1)-L TR=ATR(1);
    //Volatility quality index is the ratio of C-O compared to H-L. The higher the better.

    If TrueRange <> 0 and (High - Low) <> 0 Then
    VQI = ((Close - Close[1]) / TrueRange + (Close - Open) / (High - Low)) * 0.5

    // If truerange !=0 and we do have some volatility (i.e. where the
    //bar does have a length (difference between high and low != 0)
    //then VQI = (current bar close - close last bar ) / Truerange (+ (close-open of current bar ) / (high-low of current bar) * 0.5
    //the calc for truerange is available on the web do a google


    Else // if True range IS 0 (i.e. the current bar is still open
    // Then the VQI reading is set as the last bar ([1])
    VQI=VQI[1];

    //Now set VQI to the new reading which is
    //the absolute value of VQI multiplied by the (close - last close = (close this bar - open this bar) * 0.5
    //Stridsman made it more sensitive by including the price changes
    VQI = AbsValue(VQI) * ((Close - Close[1] + (Close - Open)) * 0.5);

    // iteratively adds VQI then plot the SumVQI and the 9 and 200 bar moving average of VQI
    SumVQI = SumVQI + VQI;
    Plot1(SumVQI,"");
    Plot2(Average(SumVQI,9),"");
    Plot3(Average(SumVQI,200),"");






    //VQI ranges between -1 and +1. It was offset to make it compatible with the zig function.
    Graph0=100*(SumVQI+100); //Red line
    Graph1=100*(MA(SumVQI,9)+100); //blue - 9 day moving average
    Graph2=100*(MA(SumVQI,200)+100); //black line - 200 day MA
    Graph2Style=1;
    Graph3Style=1;
    Graph3=Zig(Graph0,1); //yellow line indicates trend change
    Graph3Color=7;

    //Buy at the bottom zig peak for stocks over $4
    BuyIt=(C>4) AND (Graph3>Ref(Graph3,-1)) AND (Ref(Graph3,-2)>Ref(Graph3,-1));

    //Buy as before but only if the 200 day VQI is increasing. Stridsman considers
    it better if quality is improving. Comment out the next line to get more buy
    action.
    BuyIt= BuyIt AND(Graph2>Ref(Graph2,-5));

    Buy=BuyIt;

    //Sell signals are generated when the Zig Line is decreasing.
    Sell=(Graph3<(Ref(Graph3,-1))) AND (Ref(Graph3,-2)<Ref(Graph3,-1)) AND (C>3);

    //It is assumed that transactions are made the next day after a buy/sell
    signal.
    BuyPrice=ValueWhen(Ref(Buy,-1),Open,0);
    SellPrice=ValueWhen(Ref(Sell,-1),Open,0);



    Now send me the ES code please !

    Comment


    • #3
      Thanks for that, I will have a go at getting it coded tomorrow and will keep you posted.

      What has sparked my interest in this particular indicator is this:



      Now I am not a MetaTrader user (obviously), but I had a good look at the performance of that indicator and it was very good. I felt getting it coded into e-signal (or a version of it), would benefit many people strategies including my own.

      Comment


      • #4
        I think I have got the idea of it, but whats ref in the calculation for the TrueRange ?

        Comment


        • #5
          rogerha
          Ref() is used in some languages (Metastock or Amibroker for example) to reference a prior value of a data array so for example Ref(C, -1) is the close of the prior bar ie the efs equivalent of close(-1)
          Alex

          Comment


          • #6
            Thanks Alex, your help is always valuable, sorry for putting this in the wrong thread before.

            OK, here is my first pass at this code. I have added comments to highlight what I am attempting to do.

            The only thing is, I have absolutely no idea whether this is right or not. So I would welcome comments/suggestions.
            Attached Files

            Comment


            • #7
              If you pull up MSFT on the daily for the same period on eSignal, you'll see the indicator does look different to the tradestation snapshot below.

              Comment


              • #8
                Yeah thanks for that, but I don't trade Stocks. Neither does my current E-Sig subscription allow for that.

                Comment


                • #9
                  In fact, since you were going to learn EFS 'this weekend' perhaps you could be more productive.

                  Comment


                  • #10
                    Originally posted by rogerha
                    In fact, since you were going to learn EFS 'this weekend' perhaps you could be more productive.
                    Too many systems... never enough time. I need to work on that.

                    Comment

                    Working...
                    X