Reply

highest close in the past 50 bars

7 replies

onis_uk

Subscriber, bbp_participant, community, 27 replies.

Visit profile

8 years ago #114141

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

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

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

0

onis_uk

Subscriber, bbp_participant, community, 27 replies.

Visit profile

8 years ago #132410

like this ??

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

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

8 years ago #132453

On the right side set period to 1 instead of Lookback

0

luk85

Customer, bbp_participant, community, 10 replies.

Visit profile

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?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

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

0

luk85

Customer, bbp_participant, community, 10 replies.

Visit profile

8 years ago #133267

Thank you, I’m going to test that.

0

TJ#

Customer, bbp_participant, community, 144 replies.

Visit profile

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. 

0

Viewing 7 replies - 1 through 7 (of 7 total)