Reply

Stop below low of previous candle

24 replies

slowbutsure

Subscriber, bbp_participant, community, 63 replies.

Visit profile

10 years ago #112031

Hi

 

Can anyone help with how I tell EA Wizard to place a stop loss below the low of the 2nd candle back?

 

Thanks

 

 

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124111

Hello,

 

the problem is indeed in pips and functions around them.

 

You have defined

PipDistance = (Open[1] – Close[1])

 

and then you have in condition (not exactly the same way, but same effect):

IF (PipDistance > 15)

 

This will never be true, because PipDistance is in “real” pips.

 

Open[1] is for example 1.6234, Close[1] could be 1.6111.

So PipDistance = 1.6234 – 1.6111 = 0.0123, and 0.0123 will never be bigger than 15.

 

There are two possibilities which are both correct:

1, use function ConvertToPips() for PipDistance, for example

IF ConvertToPips(PipDistance) > 15 

 

this will work, because the function will convert “real” pips value 0.0123 to 123 pips, so it will compare 123 > 15

 

 

2. use funciton ConvertToRealPips() for the right side of comparison, example:

IF PipDistance > ConvertToRealPips(15)

 

this will work as well, because in this case 15 pips will be converted to “real” pips value, which is 0.0015. So it will compare 0.0123 > 0.0015

 

I hope it is clear now how it works with pips and prices.

 

 

 

.

Mark
StrategyQuant architect

0

slowbutsure

Subscriber, bbp_participant, community, 63 replies.

Visit profile

10 years ago #124115

IM just a bit confused with it.  Could you fix the file I uploaded and then I will see what you have done.

 

Thanks

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124117

Hello,

 

I’m posting corrected strategy.But you should try to understand my explanation in the previous post, otherwise you’ll not be able to use the program.

Mark
StrategyQuant architect

0

slowbutsure

Subscriber, bbp_participant, community, 63 replies.

Visit profile

10 years ago #124120

Thanks, I do want to understand it.  However, the version you gave still doesn’t enter any trades.

0

slowbutsure

Subscriber, bbp_participant, community, 63 replies.

Visit profile

10 years ago #124121

In the first rule, you have convert to pips,  and in the second convert to real pips.  Could that be the issue?

0

slowbutsure

Subscriber, bbp_participant, community, 63 replies.

Visit profile

10 years ago #124144

Mark, I’m going away soon and would really like to do this before I do, if you have time to respond.  thanks.

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124174

Hello,

 

in the strategy I didn’t check for logic, only for how you use the pips values.

 

I found several problems in the strategy:

 

1. problem with variable types – I added ConvertToPips function to the PipDistance assign variable, because it was type int, it cannot hold the difference in prices which is decimal.

 

2. you had a condition there High[0] > High[0] which is never true, I deleted it

 

3. you also had PipDistance = Open[1] – Close[1], but in the IF condition you compte it only if Close[1] > Open[1] so this difference is always negative number, which would never be bigger than 15.

So I changed the order in the subtraction to PipDistance = Close[1] – Open[1]

 

 

Mark
StrategyQuant architect

0

mantadiver

Subscriber, bbp_participant, community, 33 replies.

Visit profile

9 years ago #124699

I am trying to do a similar thing but applying a buffer to the entry price rather than a stoploss.

 

The example shows how to work with a variable and I can see how to do this with a stop or limit order but I want to code it so that the strategy enters at (let’s say) last high + 1 pip. This will likely be too close within the spread to place a stop order so I need a way to say – enter at market when price reaches last high + 1 pip.

 

I cannot see how to do this in the THEN area with a market order so I assume it needs to be an IF statement. 

 

I’m sure it’s really simple but would appreciate pointing in the right direction.

 

Many thanks.

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #124732

Hello,

 

see the attached sample. If you want to enter at market then you have to make a condition that checks if price reached last High + 1 pip.

 

Mark
StrategyQuant architect

0

Viewing 9 replies - 16 through 24 (of 24 total)

1 2