Perfect entry points

 

Hello all:

Long time trader, new to programming, have a quick question, I would really appreciate anyone that could help me out!

In programming the Williams %R to buy/sell when it crosses the trigger line, I am having a problem with the fact that on a H1 chart, The Williams % R value may dip down below/above the trigger line for a split second, trigger the order, and then immediatley come back above/below the trigger line. How do I program the EA so that it doesn't signal an order until the Williams CLOSES above/below trigger line?

Here's the piece of code for a buy signal

williamsrcurrent = iWPR (NULL, 0, 50, 0);
williamsrprevious = iWPR (NULL, 0, 50, 1);

isBuying = (williamsrprevious < -80 && williamsrcurrent > -80);

Thanks, happy trading,

Pat

 
FXpipclash:

Hello all:

Long time trader, new to programming, have a quick question, I would really appreciate anyone that could help me out!

In programming the Williams %R to buy/sell when it crosses the trigger line, I am having a problem with the fact that on a H1 chart, The Williams % R value may dip down below/above the trigger line for a split second, trigger the order, and then immediatley come back above/below the trigger line. How do I program the EA so that it doesn't signal an order until the Williams CLOSES above/below trigger line?

Here's the piece of code for a buy signal

williamsrcurrent = iWPR (NULL, 0, 50, 0);
williamsrprevious = iWPR (NULL, 0, 50, 1);

isBuying = (williamsrprevious < -80 && williamsrcurrent > -80);

Thanks, happy trading,

Pat

One way would be instead of 0,1 use 1,2. you'll be making your decision at the first tick of bar 0 based on the bar that just closed.

 
paranoidtruth wrote >>

One way would be instead of 0,1 use 1,2. you'll be making your decision at the first tick of bar 0 based on the bar that just closed.

Thanks i'll give it a shot!

 
paranoidtruth wrote >>

One way would be instead of 0,1 use 1,2. you'll be making your decision at the first tick of bar 0 based on the bar that just closed.

In fact, somtimes other indicators have this kind of "problem" too, i's all because of the price changing up and down quickly.

 
FXpipclash wrote >>

Hello all:

Long time trader, new to programming, have a quick question, I would really appreciate anyone that could help me out!

In programming the Williams %R to buy/sell when it crosses the trigger line, I am having a problem with the fact that on a H1 chart, The Williams % R value may dip down below/above the trigger line for a split second, trigger the order, and then immediatley come back above/below the trigger line. How do I program the EA so that it doesn't signal an order until the Williams CLOSES above/below trigger line?

Here's the piece of code for a buy signal

williamsrcurrent = iWPR (NULL, 0, 50, 0);
williamsrprevious = iWPR (NULL, 0, 50, 1);

isBuying = (williamsrprevious < -80 && williamsrcurrent > -80);

Thanks, happy trading,

Pat

Hi,

Just program it to open your order when a candle is opening while the WPR is set for triggering.

You can use iOpen() to get the price at the opening of the candle if you need it, iTime (...,0) to get the opening time of the candle (may be you will need to check it with the current time) and iWPR with that iTime in the shift parameter to get the WPR at the opening.

Hope it helps.

Reason: