Weird iCustom-Value

Back to topics list To post a new topic, please log in or register
avatar
22
TTromberino 2015.11.19 11:58
 

Hello there,

i have a question: Maybe you know the super trend indicator. I want to use it for my StopLoss.

But somehow this is crazy: When i ask for it´s value on the chart it looks very normal! It shows the normal price on the chart, that it should have.

But when i ask in the code for the value i get something like this: SLLONG: 214783646; Ordersend error 130; Ordersend -1 successfully.

I think i get the ordersend error from that weird stoploss. Do you know what i could have done wrong?

Here is how i use it:

double sl_long = iCustom(NULL,0,"SuperTrend",10,3.0,0,1)-abst*Point;
double sl_short = iCustom(NULL,0,"SuperTrend",10,3.0,0,1)+abst*Point;

....

if(....){
int sl = sl_long;
Print("Sllong", sl);
int ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,sl_long,0,"my order",16384,0,Green);
if (ticket){
....
}
}

(The same with short positions)

 

I would be super glad if you could help me out, i´m sitting on this problem for days now.

Best regards

 

PS: I´m sorry for the short version of the code, but something is wrong with this website on the edge browser. You cannot press enter...that´s why i had to type on my macbook.

So i had to type the code by hand :)

 

 

avatar
Moderator
3418
GumRai 2015.11.19 12:39 #
 

Looks like the indicator is returning EMPTY_VALUE

 

int ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,sl_long,0,"my order",16384,0,Green);
if (ticket){

 OrderSend returns an integer, so don't check it as if it is a boolean.

OrderSend only returns a positive integer for the ticket number if the trade is successful or -1 if it fails. It never returns 0.

It doesn't matter whether the trade is successful or not. ticket will either be a positive integer or -1 and

 

if (ticket)

 will return true for both

avatar
13000
WHRoeder 2015.11.19 12:49 #
 
TTromberino: Maybe you know the super trend indicator. SLLONG: 214783646;
  1. Don't expect us to know which of the dozen versions you are using and whether it's the version that works on build 600.
  2. List of MQL4 Constants - MQL4 Documentation -> Other constants - MQL4 Documentation ->

    EMPTY_VALUE

    Empty value in an indicator buffer. Default custom indicator empty value

    2147483647 (0x7FFFFFFF)


  3. Detailed explanation of iCustom - MQL4 forum
  4. This version has two buffers up/down but you aren't using the second.
    double sl_long = iCustom(NULL,0,"SuperTrend",10,3.0,0,1)-abst*Point;
    double sl_short = iCustom(NULL,0,"SuperTrend",10,3.0,0,1)+abst*Point;
avatar
22
TTromberino 2015.11.19 15:54 #
 
WHRoeder:
  1. Don't expect us to know which of the dozen versions you are using and whether it's the version that works on build 600.
  2. List of MQL4 Constants - MQL4 Documentation -> Other constants - MQL4 Documentation ->

    EMPTY_VALUE

    Empty value in an indicator buffer. Default custom indicator empty value

    2147483647 (0x7FFFFFFF)


  3. Detailed explanation of iCustom - MQL4 forum
  4. This version has two buffers up/down but you aren't using the second.

First of all thank you for replying so fast!

 @GumRai So if i wanna use this i have to say

if(ticket < 0) Print("fail");
else Print("success");

 So if it fails, i get a value below 0 and above 0 it was a success...correct?

 

@WHRoeder 1.: I´m sorry of course you cannot know. Here you go: http://www.forex-indikatoren.com/super-trend-indikator

2.: Thank you very much! I think i got it now! This means that my indicator doesn´t return a value. Instead he just says above or below price, right?

So how can i get the value of the indicator then? O.O

3.: I don´t get that...Do you mean i have to say MODE_SMA instead of 0 because i use an EA?

4.: I thought there you have to insert which mode of the indicator you want? SMA or EMA?

 

I´m sorry for asking stupid questions but i´m pretty new to this language and i thyhard on this ea since some weeks^^

 

Thanks for giving advice :)

 Best regards 

 

avatar
13000
WHRoeder 2015.11.19 17:15 #
 
you aren't using the second.
In one direction one buffer will have a value, the other won't.
avatar
22
TTromberino 2015.11.19 20:22 #
 

Wait....you mean "mode" is like 1 side of the buffer?

Then like  

double sl_long = iCustom(NULL,0,"SuperTrend",10,3.0,1,1); gives me the long value and

double sl_short = iCustom(NULL,0,"SuperTrend",10,3.0,2,1); gives me the short value?

And  iCustom(NULL,0,"SuperTrend",10,3.0,0,1); returns no value then? That´s why i got this weird empty_value?

 

avatar
2017
gooly 2015.11.20 08:45 #
 

Your link provide the source code and you can see:

   SetIndexBuffer(0, TrendUp);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexLabel(0, "Trend Up");
   SetIndexBuffer(1, TrendDown);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexLabel(1, "Trend Down");

That means:

This indicator has only two buffers 0 (Buy) and 1(Sell) so this "double sl_short = iCustom(NULL,0,"SuperTrend",10,3.0,2,1);" will fail!!

If you don't know the code look in the data window how many values does the indicator provides, start counting at zero!



Back to topics list  

To add comments, please log in or register