Announcement

Collapse
No announcement yet.

setPriceStudy set at runtime?

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

  • setPriceStudy set at runtime?

    Is there any way to change the setPriceStudy during runtime?

    What I would like to do is put a function parameter in premain that would allow you to toggle the state of setPriceStudy.

    So you could have it plot on the study area or on the chart and swap just by going to edit properties.

    It appears you cannont evaluate data entered in preMain, in order to set this flag. Am I missing something or is this truely a limitation.

    Regards

  • #2
    Todd

    Is there any way to change the setPriceStudy during runtime?

    I don't believe that is possible.
    You may want to send a suggestion to [email protected]
    Alex

    Comment


    • #3
      I know the question was not directed at me, however, I have tried before and failed to accomplish this with a simple reload or reloadEFS() command.

      The code posted below is the closest I came. It sets a global variable, then when the efs is removed and subsequently reloaded, it loads in the window as determined by the global variable set before.

      PHP Code:
      var flag false;

      function 
      preMain(){
          
      flag getGlobalValue ("setting");
          if (
      flag==null)flag=true;
          
      setPriceStudy(flag);
        
      }
      function 
      main(){

        if (
      getCurrentBarIndex() < -)return;

        
      getButtons();
      //
      //
      }
      function 
      getButtons(){
        
      drawTextPixel(2150"load in Price window = "+flag+"@URL=EFS:nSwitch",  Color.rednull,Text.LEFT|Text.VCENTER|Text.FRAME"Courier New"11,"text4"); 

      }
      function 
      nSwitch(){

        if (
      flag)flag false;
        else 
      flag=true;
        
      setGlobalValue ("setting"flag); 
        
      debugPrintln("load in Price window = "+flag);
        
      getButtons();

      Attached Files

      Comment


      • #4
        Steve,

        The methodology you suggest does work, I have studies that do this.

        One example of this is where I needed the number of bars loaded in the chart to determine what to do in preMain(). But of course getOldestBarIndex() doesn't work in preMan(). So I did the following - in main() I did this:


        var nNumBars = getGlobalValue ("GnNumBars");

        if (nNumBars == null){
        nNumBars = getOldestBarIndex();
        setGlobalValue ("GnNumBars", nNumBars);
        reloadEFS();
        }

        and in PreMain() I did something like:

        var nNumBars = getGlobalValue ("GnNumBars");
        if (nNumBars == null){
        } else {
        ...
        }


        This worked just fine. I have also done this when I needed to iterate all the bars first and then used some calculations to determine some formatting issues that could only be done in preMain(). So I would verify if this was the first time the EFS was run, and if so I waited for the current bar index to be 0, did my calcs, set my universal global and then did a reloadEFS(). If not then I just did a return knowing that the all the setup had been done in preMain() and then reset the universal global.

        Garth
        Garth

        Comment


        • #5
          Steve just pointed out to me, that in specific you wanted to do setPriceStudy(). This is an odd beast in eSignal and I do agree with Alex and Steve - there is likely no way to do this.

          In general if you do send an email with a request for enhancement I would ask for allowing us to have a single EFS that writes to both the price pane and a study pane. This is much more flexible and powerful - and has been requested multiple times. Maybe if they get enough requests they will fix this (kind of broken IMHO) aspect of EFS.

          Garth
          Garth

          Comment

          Working...
          X