Coding help - page 485

 
NWFstudent:
Let say you are trading the 1hour chart and you use a mtf indicator displaying the 4hr chart, then i want the setting to be use next time frame.

ie. i am trading the 1hr chart and the indicator are using 4hr data, when i swap my time frame to 4hr i want the indicator to swap to the timeframe above 4hr, so now it will use the daily data.

I found this thread, but as im no coder im not sure where to paste to code or if it needs any modification for the actual indicator.

Next Timeframe - MQL4 forum

The indicator I want to add this to is "Traders Dynamic_Cb_ssa norm Index_alerts+arrows new 1.01" from the elite forums

NWFstudent

You can see in this one how you can do that in a simple way : https://www.mql5.com/en/forum/181187/page24 (including up to chosing 3rd higher time frame automatically)

 

Hi mladen.

Last time for a while....I promise.

As you will by now know, I'm a strong fan of the ADX indicator.

I use it in a number of ways & never enter a trade against it.

I also like the principle of the three ducks indicator

and have tried to combine the two but without any joy.

I'll give it one more try & then try something else :

The attached indicator, as far as I can see, has only area where an indicator is mentioned - Lines 54,57,60.

All else appears to be time frame related.

I have tried to remove all mention of 'sma & SMA' - & to adx & ADX, in it's place, but with no luck.

Is it possible, & if so (Without taking up too much of your time.) would let me know how.

Have a great w/end.

Files:
 
Jeeves:
Hi mladen.

Last time for a while....I promise.

As you will by now know, I'm a strong fan of the ADX indicator.

I use it in a number of ways & never enter a trade against it.

I also like the principle of the three ducks indicator

and have tried to combine the two but without any joy.

I'll give it one more try & then try something else :

The attached indicator, as far as I can see, has only area where an indicator is mentioned - Lines 54,57,60.

All else appears to be time frame related.

I have tried to remove all mention of 'sma & SMA' - & to adx & ADX, in it's place, but with no luck.

Is it possible, & if so (Without taking up too much of your time.) would let me know how.

Have a great w/end.

Jeeves

You can not use adx instead of sma in that indicator. Adx values are in a completely different range of values and can not be compared to Bid as that indicator is doing in the code

 
mladen:
NWFstudent You can see in this one how you can do that in a simple way : https://www.mql5.com/en/forum/181187/page24 (including up to chosing 3rd higher time frame automatically)

Thanks, it was straight forward copy paste

 

Dear,

can someone help me.

what happend on this " invalid ticket for OrderModify function"

But in other can trade it.

extern double lots = 0.1;

extern double stopsize = 200;

extern double profsize = 100;

extern double Risk =0.01;

int err;

int ticket;

double stop;

double prof;

int init() { return(0); }

int deinit() { return(0); }

int start()

{

int TotalOrders = 0;

for (int i=0; i <= OrdersTotal(); i++)

{

if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

if (OrderSymbol() == Symbol())

TotalOrders++;

}

if (TotalOrders<1)

{

ticket=OrderSend(Symbol(), OP_SELL, getLots(Risk), Bid, 3, 0, 0, NULL,LimeGreen);

stop=(Bid+stopsize*Point);

prof=(Bid-profsize*Point);

OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Blue);

}

err=GetLastError();

Comment(" ");

}

 
hock87:
Dear,

can someone help me.

what happend on this " invalid ticket for OrderModify function"

But in other can trade it.

That means that your order was not accepted / executed and that the OrderSend() function returned -1 as a result. Always check if that ticket number is > -1 before trying to modify a newly created order

 

Any examples of simple file (not history files) usage?

 
mladen:
xtractalpha Will have to test it to see what is happening. If I find what is the problem, will post it here

Dear Mladen,

Do you have any updates about my request?

Enjoy your weekend

Thanks in advance,

Thierry

 
xtractalpha:
Dear Mladen,

Do you have any updates about my request?

Enjoy your weekend

Thanks in advance,

Thierry

Thierry

Delete lines 74 and 137 of your code (you are calling LotsizeCalc() function from both lines and that way you are artificially pushing up lot size on each and every tick)

After deleting those lines it should work OK

 
mladen:
Thierry

Delete lines 74 and 137 of your code (you are calling LotsizeCalc() function from both lines and that way you are artificially pushing up lot size on each and every tick)

After deleting those lines it should work OK

Thanks for your fast response!

I've deleted the lines, but the EA is still opening trades with the wrong lotsize.

It's really strange why the EA is ignoring my Martingale code. Because the EA is only opening trades with lotsize 0.10 or 0.20.... (see the picture).

Screenshot by Lightshot

I think my lotsizecalc function has to be the problem. I want the function to multiply my lotsize by the martingale amount when I lose a trade.

My martingaleamount is 1.5 and my lotsize is 0.10 . This means when I lose 5 trades in a row the lotsizes will be : 0.1 , 0.15 , 0.22 , 0.34 , 0.51 .

double LotsizeCalc() { if(lastOrderProfit()<0 && tradeNumber <=MaximumTrades) { tradeNumber++; malot=OrderLots()*MartingaleAmount; } else { malot = LotSize; tradeNumber=1; } return(malot); }

Could anyone check this code?

Thanks in advance,

Thierry

Reason: