icustrom buffer-get values from indicator buffers

 

I am trying to write ea that will place buy when the indicator show arrow sell or buy. I am using icustorm to do that but i am struggling with comparing values.


here is my code:


       void OnStart()

  {

//---

       double sell=iCustom(NULL,0,"myIndi",0,0);

       double buy=iCustom(NULL,0,"myIndi",1,0);

       

       if(sell>0)//sell

       {

        //check if buy trade is running

        //close a buy trade

        //open a sell trade on success

         if(buyTicket>0)

          {

            bool ret=OrderClose(buyTicket, lot, Bid, slipage,clrBlue);

            if(ret==true)

              {

                printf("the sell number is: "+sell);

                sellTicket=OrderSend(Symbol(),OP_SELL,lot,Bid,slipage,NULL,NULL,"MATHUNYA SELL",magic,0,clrRed);

              }

          }

         else

         {

           //we dont have a buy trade open

           //place a sell trade

           //only one trade should be open

           if(sellTicket>0)

           {

             printf("sell order already running");

           }

           else

           {

             printf("the sell number is: "+sell);

             sellTicket=OrderSend(Symbol(),OP_SELL,lot,Bid,slipage,NULL,NULL,"MATHUNYA SELL",magic,0,clrRed);

           }     

         }            

       }

       else{

         Print("buy: "+buy+", sell: "+sell+" Time: "+TimeToStr(Time[1]));

         printf("awaiting sell order..");

       }

       

       if(buy>0)//buy

       {

       //check if sell trade is running

       //close a sell trade

       //open a buy trade on success

         if(sellTicket>0)

          {

            bool ret=OrderClose(sellTicket, lot, Ask, slipage,clrYellow);

            if(ret==true)

              {

                printf("the buy number is: "+buy);

                buyTicket=OrderSend(Symbol(),OP_BUY,lot,Ask,slipage,NULL,NULL,"MATHUNYA BUY",magic,0,clrGreen);

              }

          }

         else

         {

           //we dont have a sell trade open

           //place a buy trade

           //only one trade should be open

           if(buyTicket>0)

           {

             printf("buy order already running");

           }

           else

           {

              printf("the buy number is: "+buy);

              buyTicket=OrderSend(Symbol(),OP_BUY,lot,Ask,slipage,NULL,NULL,"MATHUNYA BUY",magic,0,clrGreen);

           }     

         }          

       }else

       {

         Print("buy: "+buy+", sell: "+sell+" Time: "+TimeToStr(Time[1]));

         printf("awaiting buy order..");

       }

      return (0);

  }


//global variables

int buyTicket=0;

int sellTicket=0;

double lot=0.01;

int slipage=3;

int magic=321;


the problem is my ea place trade even if the arrow did not show. and also it close only the second order and leave the rest open.


anyhelp would be appriciated

 
Mathunya: I am using icustorm to do that but i am struggling with comparing values.
  1. Please use
SRC
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. double sell=iCustom(NULL,0,"myIndi",0,0);
    if(sell>0)//sell
    What value does your indicator use as an empty value (SetIndexEmptyValue?) Are you sure it is zero? Or does it default to EMPTY_VALUE?
 
whroeder1:
  1. Please edit your post.
    For large amounts of code, attach it.

  2. What value does your indicator use as an empty value (SetIndexEmptyValue?) Are you sure it is zero? Or does it default to EMPTY_VALUE?

i havew this line in myh code:

Print("buy: "+buy+", sell: "+sell+" Time: "+TimeToStr(Time[1]));

here is the output:

0 16:25:27.012 testing EURUSD,M1: buy: 0, sell: 0 Time: 2017.07.18 17:24

 
Alain Verleyen:


  I have attached my ea mq4 file as well as the image to show my indicator buffer values


here is a code from the indicator i am reading from:

IndicatorBuffers(2);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 234);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 233);
   SetIndexBuffer(0, G_ibuf_92);
   SetIndexBuffer(1, G_ibuf_96);
   GlobalVariableSet("AlertTime" + Symbol() + Period(), TimeCurrent());
   GlobalVariableSet("SignalType" + Symbol() + Period(), 5);
   return (0);
<decompiled code removed>
Files:
chart.fw.png  163 kb
 
Mathunya:
   SetIndexBuffer(0, G_ibuf_92);
   SetIndexBuffer(1, G_ibuf_96);

Ask the owner of the indicator to give source code to you.

Decompiled code is stolen code. Either you are a thief, a fence, or the receiver of stolen (intellectual) property. Either way we will not be an accomplice after the fact to theft. See also forum.mql4.com/41864#490649

If you post decompiled code again, you will likely be banned.

Don't tell us you found it on the 'net: if someone stole your bank details and uploaded them on to the internet, is it OK for everyone to use them because "someone uploaded it, I don't know why I can't use that"?

Reason: