highest close in the past 50 bars
7 replies
onis_uk
8 years ago #114141
how would i go about coding “highest close in the past 50 days” ?
tomas262
8 years ago #132388
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
onis_uk
8 years ago #132410
tomas262
8 years ago #132453
On the right side set period to 1 instead of Lookback
luk85
8 years ago #133239
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?
tomas262
8 years ago #133257
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
luk85
8 years ago #133267
Thank you, I’m going to test that.
TJ#
8 years ago #135165
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 7 replies - 1 through 7 (of 7 total)