Announcement

Collapse
No announcement yet.

Selecting Which Price To Use

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

  • Selecting Which Price To Use

    I want to set up a parameter in preMain that allows me to pick which price to use in setting a trigger -- high, low, open, close. Then, in main, I need to get that price but I don't want to create a series.

    If I select "high" in the paramaters, the statement in main would need to select the current high price.

    Like: triggerPrice = high(0);

    It's not clear to me how to construct the above statement in main to use a variable from preMain which has the type of price selection. I can't seem to find any examples.

    Thanks.

  • #2
    AssetHound
    In preMain set up a FunctionParameter eg
    var fp00 new FunctionParameter("Source", FunctionParameter.STRING);
    fp00,addOption("close");
    fp00.addOption("high");
    fp00.setDefault("close");

    Add the parameter to the main declaration then in the main function enclose the parameter Source in an eval() function to evaluate the string
    var triggerPrice = eval(Source)(0);
    For more detailed examples see the studies included in the EFS2 Custom folder
    Alex

    Comment


    • #3
      Thanks, as always. Very helpful.

      Originally posted by Alexis C. Montenegro
      AssetHound
      In preMain set up a FunctionParameter eg
      var fp00 new FunctionParameter("Source", FunctionParameter.STRING);
      fp00,addOption("close");
      fp00.addOption("high");
      fp00.setDefault("close");

      Then in main enclose the parameter Source in an eval() function to evaluate the string
      var triggerPrice = eval(Source)(0);
      For more detailed examples see the studies included in the EFS Custom folder
      Alex

      Comment


      • #4
        AssetHound
        As always my pleasure
        Alex

        Comment

        Working...
        X