# Some custom blocks throw exceptions

1 replies

3 weeks ago #286249

Hi, I’m new to SQX. I started playing around with custom blocks in AlgoWizard, but some throw exceptions in the SQX Builder (138.1978) that I’m having trouble figuring out.

I tried a set of Filter Blocks that would only allow trades if the price is within or beyond a certain percentage of today’s open or yesterday’s close

Price within percentage from today’s open:

Close[Chart, 1] < (OpenD[Chart, 1] + (OpenD[Chart,1)/(100*percent)))

Price beyond percentage from today’s open:

Close[Chart, 1] > (OpenD[Chart, 1] + (OpenD[Chart,1)/(100*percent)))

Price within percentage from yesterday’s close:

Close[Chart, 1] < (CloseD[Chart-Daily, 1] + (CloseD[Chart-Daily,1)/(100*percent)))

Price beyond percentage from yesterday’s close:

Close[Chart, 1] > (CloseD[Chart-Daily, 1] + (CloseD[Chart-Daily,1)/(100*percent)))

where percent is a double from 0.5 to 5 with 0.1 step size.

I didn’t configure any opposing blocks, as the conditions should be the same for both long and short trades, is that ok?

I also tried a block for only allowing trades within a certain time block (to be able to use this condition for parameter search) and it also throws exceptions:

Hour[0] > hourp AND Hour[0] < (hourp + 1) AND Minute[0] > minute1 AND Minute[0] < Minute 2

there are 3 int variables, hourp, minute1 and minute2.

Finally, a block where Stochastic %K crosses Stochastic %D only when above or below levels also throws exceptions (without the levels it works ok):

Stoch(per1, per2, per3).Fast%K[1] crosses above Stoch(per1, per2, per3).Slow%F[1] AND Stoch(per1, per2, per3).Fast%K[1] > level2

per1, per2, per3 are periods for the stochastic parameters, level1 and level2 are overbought/oversold levels int variables. The opposing block is “crosses below” and < level 1.

What am I doing wrong in each case?

Finally, the first block I did was a simple moving average crossover, to learn how everything worked. But I could not find a way to define the moving average type (simple, exponential) as a variable to be optimized, is it possible?

###### Attachments:
You must be logged in to view attached files.

2 weeks ago #286278

Can you please export the blocks and send us to [email protected]? We will test it

Viewing 1 replies (of 1 total)