Need help please with buy sell code - page 2

 

....

First set the conditions like this (if you want the EA to open position on trend change)

double currentTrend = iCustom(NULL, 0, "nonlagdot", Price,Length,Displace,Filter,Color,ColorBarBack,Deviation, 4, Current + 0);

double previousTrend = iCustom(NULL, 0, "nonlagdot", Price,Length,Displace,Filter,Color,ColorBarBack,Deviation, 4, Current + 1);

if (currentTrend != previousTrend)

if (currentTrend==1 ( code for buy }

else { code for sell }

All you need to test is the trend buffer (the number 4 in the place where buffer is specified), nothing else, Also set the eachTickMode to false and then it will open positins only on closed candle (since it is going to look for signals only on candle close)

pacinvest:
Ok

I have got the buy sell code working using trend buffer as you suggest, but I still have exactly the same two problems as above with trades not being executed at candle close, or I think that is what is going wrong.

Thanks for the help guys, starting to understand this better now.
 

Ok

Thanks Passenger

That makes sense. I will give it go and see if I can put the code together with out screwing up. Kinda of a slow process but with you guys helping a bit I am progressing. This will go down as the slowest and most boring thread in FXtsd history, but maybe useful for newbie coders..............Anyway much appreciated....

 

A little clarification please

Hi Passenger

I am doing well now with the simple buy logic nldtrend > 0 for buy etc. When I set eachtickmode to false everything started working as it is meant to do. Awesome thanks.

I have been thinking about the code you wrote above and I would like a little explanation if possible because I want to understand the code.

I understand the buffer variable definition OK but then the buy sell logic is not clear to me:

if (currentTrend != previousTrend)

if (currentTrend==1 ( code for buy }

else { code for sell }

So the first part of the if statement makes sure that the current nld color or trend is not the same as the previous bar, meaning that what we are looking for is a bar where the nld color has changed. Then when there is a second if statement I take it this means that both conditions must be met. I would have thought that we want currentTrend > 0 rather == 1. What does the 1 come from or mean? Then the else part of the statement, does this mean if currentTrend is anything other than 1 that a sell is called for?

Sorry about all the questions but I am wanting to be clear on this.

Thanks again for the help.............................

 

...

You are right about the first part : if current trend value is not the same as previous trend value, then there is a change in trend. In that case all we have to do is to find out what is the current trend. Since trend buffer can contain only 2 values (+1 for trend up and -1 for trend down) then the second part that is entered only if the first part is true, finds out what is the current trend

regards

pacinvest:
Hi Passenger

I am doing well now with the simple buy logic nldtrend > 0 for buy etc. When I set eachtickmode to false everything started working as it is meant to do. Awesome thanks.

I have been thinking about the code you wrote above and I would like a little explanation if possible because I want to understand the code.

I understand the buffer variable definition OK but then the buy sell logic is not clear to me:

if (currentTrend != previousTrend)

if (currentTrend==1 ( code for buy }

else { code for sell }

So the first part of the if statement makes sure that the current nld color or trend is not the same as the previous bar, meaning that what we are looking for is a bar where the nld color has changed. Then when there is a second if statement I take it this means that both conditions must be met. I would have thought that we want currentTrend > 0 rather == 1. What does the 1 come from or mean? Then the else part of the statement, does this mean if currentTrend is anything other than 1 that a sell is called for?

Sorry about all the questions but I am wanting to be clear on this.

Thanks again for the help.............................
 

Understood

Thanks Passenger

Ok that is helpful I just didn't know what values the trend buffer (mode =4) was generating. I have got everything happening now so will spend some time testing. As everyone who is experienced at this stuff has long ago learned these two indicators nonlagdot and QQE are dynamite when markets are on the move, but they can become dogs when the price action is ranging in 'tight' cycles or consolidating -not always the same thing.....

So it comes down to having an EA you supervise turning on and off, running EA in long only or short only trading with major trend or employing an additional logic or filter(s). All this is of course affected by time frame used and currency pair. Note there is also a lot of information in the QQE signals themselves that could be used in different ways like slope and position of the lines which could get the EA out of certain situations.That's what I am working on with my manual trading which got me going on the EA approach. Hopefully now I can work away it and see how I go. There has to be potential there with this approach.

In the spirit of FxTSD I will tidy up the basic EA and post soon and then go from there. These two indicators are great indicators so there may be others that want to go back to the basics and test ideas.

Thanks for the great assistance.

Reason: