Coding help - page 676

 

Hi friends,

I try to make an EA which buy when two indicators indicate (both has to do it), and sell when the same indicators indicate. If one of the two indicators changes and an order is open, the order should be closed. 
I tried this, but don't understand:

#define _doNothing 0
#define _doBuy     1
#define _doSell    2
int start()
{
   int doWhat = _doNothing;
      double hull_trend_current  = iCustom(NULL,0,"StepMA of rsi adaptive ema 2.8",PERIOD_CURRENT,RsiType,RsiLength,RsiPrice,Sensitivity,StepSize,Filter,FilterPeriod,FilterOn,10,BarToUse);
      double hull_trend_previous = iCustom(NULL,0,"StepMA of rsi adaptive ema 2.8",PERIOD_CURRENT,RsiType,RsiLength,RsiPrice,Sensitivity,StepSize,Filter,FilterPeriod,FilterOn,10,BarToUse+1);
      double hull_trend_current2  = iCustom(NULL,0,"step one more average 2.3 mtf",PERIOD_CURRENT,11,BarToUse);
      double hull_trend_previous2 = iCustom(NULL,0,"step one more average 2.3 mtf",PERIOD_CURRENT,11,BarToUse+1);
      if (hull_trend_current!=hull_trend_previous && hull_trend_current2!=hull_trend_previous2)
         if (hull_trend_current==1 && hull_trend_current2==1)
               doWhat = _doBuy;
         else  doWhat = _doSell;
         if (doWhat==_doNothing && !DisplayInfo) return(0);
         

 This only open orders when both indicators do the same change on the same bar.

 
simon_json:

Hi friends,

I try to make an EA which buy when two indicators indicate (both has to do it), and sell when the same indicators indicate. If one of the two indicators changes and an order is open, the order should be closed. 
I tried this, but don't understand:

 This only open orders when both indicators do the same change on the same bar.

The way you are checking them when either of the conditions is true, then you have a by or sell (not when both conditions are true). Is that what you wanted?
 

Hi;

Can anyone help with the attached auto fib indi? I want to be able to add or delete fib levels. I have tried to play with the code but no matter what I do it will only show the original default levels. Appreciate any help.

Thanks

Files:
Fibos.mq4  5 kb
 
speedytina:

Hi;

Can anyone help with the attached auto fib indi? I want to be able to add or delete fib levels. I have tried to play with the code but no matter what I do it will only show the original default levels. Appreciate any help.

Thanks

Post the attempt when you tried to add levels so that we can help you out with coding
 
mladen:
The way you are checking them when either of the conditions is true, then you have a by or sell (not when both conditions are true). Is that what you wanted?

Thanks for reply!
I want to buy when both indicators indicate (say both are green). If one turns red (sell) EA should exit buy. If the same indicator turns green again (so both are green) EA should buy again. And the same for sell-orders;

I want to sell when both indicators indicate (say both are red). If one turns green (buy) EA should exit sell. If the same indicator turns red again (so both are green) EA should sell again.

So they are kind of filter each other out.  

 
simon_json:

Thanks for reply!
I want to buy when both indicators indicate (say both are green). If one turns red (sell) EA should exit buy. If the same indicator turns green again (so both are green) EA should buy again. And the same for sell-orders;

I want to sell when both indicators indicate (say both are red). If one turns green (buy) EA should exit sell. If the same indicator turns red again (so both are green) EA should sell again.

So they are kind of filter each other out.  

simon

as per my observation,do not close trade on one indicators opposite signals ,it might be a false/short signal,close on some thing else or when all two turn opposite or by take profit limit .... lastly close a portion of (say 50 %) that trade if you want use your first method.

 
mladen:
Post the attempt when you tried to add levels so that we can help you out with coding

Thanks mladen.

I'm trying to add fib level 0.764.

I changed code lines 71 and 88 from fib level 1.618 to 0.764. It compiled ok. However when I load the revised indi to a chart, it continues to show level 1.618 even though in is no longer in the code. Level 0.764 does not show even though it is now in the code instead of 1.618.

I also tried to add an additional line of code in addition to the 5 default levels. That did not work either. Instead of code lines "f_1[i] to f_7[i]" I increased to "f_1[i] to f_8[i]"

Thanks for any help

 
speedytina:

Thanks mladen.

I'm trying to add fib level 0.764.

I changed code lines 71 and 88 from fib level 1.618 to 0.764. It compiled ok. However when I load the revised indi to a chart, it continues to show level 1.618 even though in is no longer in the code. Level 0.764 does not show even though it is now in the code instead of 1.618.

I also tried to add an additional line of code in addition to the 5 default levels. That did not work either. Instead of code lines "f_1[i] to f_7[i]" I increased to "f_1[i] to f_8[i]"

Thanks for any help

That indicator is using buffers only as a sort of distraction. It creates a "fibo" object and then in the object, levels must be treated differently. Use the attached

Files:
Fibos.mq4  6 kb
 
mntiwana:

simon

as per my observation,do not close trade on one indicators opposite signals ,it might be a false/short signal,close on some thing else or when all two turn opposite or by take profit limit .... lastly close a portion of (say 50 %) that trade if you want use your first method.

Thanks for suggestions! Yes, sounds good. I think I might be able to code some of the suggestions on my own if i get help with the start :)
 
simon_json:
Thanks for suggestions! Yes, sounds good. I think I might be able to code some of the suggestions on my own if i get help with the start :)

I think MLADEN and stevenpun are helping you time to time and you doing it perfectly though slowly slowly :)

thanks to both.


Reason: