EA Strategy Problem

1 replies

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #112766

Hello everyone,

 

Ok, here is my problem, Let’s say that I want to create a strategy with EA Wizard. The strategy is simple.

 

Whenever CCI crosses below than “-50”  and momentum < 100 then enter “Short” and the opposite.

Whenever CCI crosses above than “+50” and momentum > 100 then enter “Long:

“Close all positions” each time CCI crosses “0”.

 

Enter At Market                                  CCI                                          MO

Symbol: Current                         Symbol: Current                        Symbol: Current

Direction: Short                          Timeframe: Current                  Timeframe: Current

Quantity: 1.0                               Period: 24                                 Period: 50

Magic Number: 1000                 Apply to: Close                          Apply to: Close

Profit Target: 20                         Shift: 1                                      Shift: 1

 

The problem is that:

 

 

Let’s say that Momentum is already on the price of “94” (meaning < than 100).

When the price of CCI is playing, between -49 and -51 (meaning that crosses CCI) for 25 times until the price be stable somewhere lower or higher, the strategy have already opened 25 entries to the market.

 

If I give order CCI < -50 and momentum < 100, then each time the candle closes below -50 , again one order will be open “Shortly”

 

 

What I am doing wrong? What do I have to do in order the strategy to take place only at once?

 

 

 

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #126988

you again posted this to StrategyQuant section, please post EA Wizard questions to EA Wizard section!

 

I don’t fully understand the logic of your strategy, could you post the sqw file here?

Mark
StrategyQuant architect

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127006

I’m really sorry Mark I posted here. Didn’t do it on purpose. When I realized it, it was too late.

 

Ok, So the strategy is simple.

 

I want to “Buy” When Momentum is > 100 and at the same time when CCI crosses above 50

I want to “Sell” When Momentum is < 100 and at the same time when CCI crosses below-50.

 

We all know that market price goes up and down all the time. The same for the price of CCI and Momentum in this example.

Now, consider that the strategy is running and Momentum is already around to 120 (which means the strategy will execute a “Buy” order), but the price fluctuate between 49 and 51 some times when finally goes up to 75.

 

My problem is that for these few times that the price was fluctuating between 49 and 51 the strategy was executing more than 1 “Buy” orders.

But of course this it doesn’t happen always.

 

So my questions are:

Is there any way to adjust the strategy avoiding open more than 1 order?

Is there something wrong with this strategy?

 

 

(Sorry, didn’t know how to post sqw file. I sent it via email.

 

Waiting for your reply.

Thanks for reading.

 

 

Regards,

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127007

Otherwise I can post the code here if you want.

 

 

 

Thank you

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127014

it would help if you could post your sqw file here.

 

Do you mean that the EA opens trade, then closes it then open it again etc. as CCI fluctuates between 49 and 51?

Because EA has a protection that it shouldn’t open multiple trades to the same direction with the same magic number, so you shouldn’t have multiple trades opened to the same direction.

 

To fix the first problem you can use variable to keep track on number fo opened trades per trend, it was mentioned here together with an example:

https://strategyquant.com/forum/topic/2268-one-trigger-per-trend-conundrum/

 

The idea is that you’ll use variable to keep track on how many trades you opened since last momentum crossing, you can limit it to open just 1 trade.

Mark
StrategyQuant architect

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127026

Actually this that I want to limit is CCI and not Momentum. Momentum in this strategy is coming 2nd as a confirmation curve to enter or not to the market, so I don’t want to limit trades according Momentum.

 

Maybe it will be helpful to say that the timeframe i’m using is a 4 Hour timeframe. All these we are talikng about fluctuation of CCI, are taking place in 1 candle of 4 hours!

 

So, is there any parameter to adjust in order the strategy to open no more than one trades / per candle ???

 

(I don’t know how to post the sqw file here. Copy paste doesn’t work. Do you want me to post the hole code of the strategy?)

 

 

Thank you

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127049

Hello Mark! Here is the sqw file you asked for.

 

 

 

 

Please have a look and tell me if there is a posibility, this strategy to open double or trible or more trades in a one 4hour candle (I use the strategy in a 4Hour Timeframe).

 

Thank you

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127050

And by the way, I noticed a small delay of strategy’s activation. (Apply to: Close) 

 

Is there anything we can do so the strategy to be ativated when the candle is closing??  

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127051

It works excellent in a 1 min Timeframe, but not in a 4 hour Timeframe.

 

Thank you

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127160

Hello,

 

I looked at this strategy, sorry it took me so long.

 

But it seems ok, can you tell me what exactly is wrong with it?

 

I understand that you want it to place just one trade per 4 hour candle, right?

 

What exactly is the problem?

 

1. that it opens a trade, it hits SL or PT and then opens the same trade on the same candle?

 

2. or that it opens multiple trades on the same candle at the same time – so you have more than one open positions?

 

If the problem is 1.) the solution is simple – add condition Order Opened This bar is False that will check if order was already opened on the current bar.

 

I’m attaching modified strategy.

 

 

 

Mark
StrategyQuant architect

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127204

Well, the problem seems to be the first one:

 

That it opens a trade, it hits SL or PT and then opens the same trade on the same candle.

 

I ll test the strategy you sent me and I will inform you.

 

By the way, the strategy I have already create it will stop working if the trial expires ???

 

 

Thank you

0

sdb

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127255

Ok Mark I did what you said and it’s ok now. But an another problem appeared.

 

If CCI is above 50 and Momentum Above 100 then we enter the market and it’s ok.

But if in the next 4hour candle the indicators continues to be above both of them, an another trade opens! I DON’T WANT THAT!

 

I want the strategy to open only one trade. But, if CCI falls below 50 and then goes again above 50 then to open a new trade.

 

The same if we go for “Short”

 

Do you think that this it can be done???

 

Please answer me  

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127266

yes, this can be done, but you have to use variables to track the trend changes.

 

Example of strategy in pseudo code:

 

Rule 1:

IF CCI falls below 0 and then returns back above 0

THEN Set variable TradesInNewTrend = 0

 

Rule 2:

if TradesInNewTrend=0 and your other condition

THEN

open trade

Set variable TradesInNewTrend = 1

 

This will keep track on how many trades were opened for every trend change.

Mark
StrategyQuant architect

0

Pit

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127407

Hi

Mark you can upload an example?

Rule 1:

IF CCI if below 0 and then returns back above 0

THEN set variable TradesInNewTrend = 0

 

Rule 2:

if TradesInNewTrend = 0 and your other condition

THEN

open trade

Set variable TradesInNewTrend = 1

Thank Pit

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127445

I’m attaching an example.

Mark
StrategyQuant architect

0

Pit

Subscriber, bbp_participant, community, 37 replies.

Visit profile

9 years ago #127703

Thanks

 

Pit

0

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