Not logged in
Viewing 8 posts - 1 through 8 (of 8 total)

Forums>AlgoWizard / EA Wizard>Application Support>highest close in the past 50 bars

  • #114141 |
    Participant
    24 Posts

    how would i go about coding “highest close in the past 50 days” ?

    #132388
    Moderator
    1559 Posts

    You will need to use a little “hack” here. Try Functions -> Indicator Highest Value and set period = 50 -> select Simple Moving Average, set period = 1 and Apply To = Close

    #132410
    Participant
    24 Posts

    like this ??

    i have applied the “lookback” variable so i can change it but its set to 50 now 

    Attachments in this forum are visible only for registered users.
    #132453
    Moderator
    1559 Posts

    On the right side set period to 1 instead of Lookback

    #133239
    Customer
    8 Posts

    Hi, this is very good idea, but I can’t set SMA period to 1. EA Wizard don’t allow to set period number  in moving avarages smaller than 2. Could you check that?

    #133257
    Moderator
    1559 Posts

    yes, you are right, it won’t accept 1 as a MA period

     

    you will probably need to add a new function into CustomFunctions.mq4 placed in /code/ folder. The code could be:

    double getHighestClose(int period) { // name of the function with parameter
       double highest = 0; // init variable to store highest value
       
       for (int i = 1; i  highest) highest = Close[i]; // check if currect bar close is greater than highest stored in "highest" variable
       }
       return(highest); // function will return calculated value
    }
    

    Then you can use this function in Wizard like it’s shown on screenshot attached

    Attachments in this forum are visible only for registered users.
    #133267
    Customer
    8 Posts

    Thank you, I’m going to test that.

    #135165
    Customer
    112 Posts

    hi,

     

    to run a  moving averages smaller than 2,,,

     

    1. set “MA_Var” int = 1

    2, use “MA_Var” as the period of the  moving averages instead 

     

    yes.. if you tries to use “2”, EA Wizard will not accept.. this is a workaround. 

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.