Carteras Blog        Login      Registrarse        

Síguenos en:   RSS   Facebook  Twitter   Linkedin   

Resultados 1 al 50 de 50
Like Tree5Likes
  • 3 Post By
  • 6 Post By
  • 3 Post By
  • 3 Post By BOLSAANGEL

Tema: Robot basado en el RSI

Ver modo hilado

Mensaje anterior Mensaje anterior   Próximo mensaje Próximo mensaje
  1. #20
    Master del Universo Avatar de mitainvest
    Fecha de ingreso
    09 feb, 13
    Mensajes
    403
    Thanks
    56
    Thanked 83 Times in 71 Posts
    Poder de reputación
    5

    Re: Robot basado en el RSI

    Ichimoku.mq4

    Código:
    //+------------------------------------------------------------------+
    //|                                                     Ichimoku.mq4 |
    //|                      Copyright © 2004, MetaQuotes Software Corp. |
    //|                                       http://www.metaquotes.net/ |
    //+------------------------------------------------------------------+
    #property copyright "Copyright © 2004, MetaQuotes Software Corp."
    #property link      "http://www.metaquotes.net/"
    
    #property indicator_chart_window
    #property indicator_buffers 7
    #property indicator_color1 Red
    #property indicator_color2 Blue
    #property indicator_color3 SandyBrown
    #property indicator_color4 Thistle
    #property indicator_color5 Lime
    #property indicator_color6 SandyBrown
    #property indicator_color7 Thistle
    //---- input parameters
    extern int Tenkan=9;
    extern int Kijun=26;
    extern int Senkou=52;
    //---- buffers
    double Tenkan_Buffer[];
    double Kijun_Buffer[];
    double SpanA_Buffer[];
    double SpanB_Buffer[];
    double Chikou_Buffer[];
    double SpanA2_Buffer[];
    double SpanB2_Buffer[];
    //----
    int a_begin;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int init()
      {
    //----
       SetIndexStyle(0,DRAW_LINE);
       SetIndexBuffer(0,Tenkan_Buffer);
       SetIndexDrawBegin(0,Tenkan-1);
       SetIndexLabel(0,"Tenkan Sen");
    //----
       SetIndexStyle(1,DRAW_LINE);
       SetIndexBuffer(1,Kijun_Buffer);
       SetIndexDrawBegin(1,Kijun-1);
       SetIndexLabel(1,"Kijun Sen");
    //----
       a_begin=Kijun; if(a_begin<Tenkan) a_begin=Tenkan;
       SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
       SetIndexBuffer(2,SpanA_Buffer);
       SetIndexDrawBegin(2,Kijun+a_begin-1);
       SetIndexShift(2,Kijun);
       SetIndexLabel(2,NULL);
       SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
       SetIndexBuffer(5,SpanA2_Buffer);
       SetIndexDrawBegin(5,Kijun+a_begin-1);
       SetIndexShift(5,Kijun);
       SetIndexLabel(5,"Senkou Span A");
    //----
       SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
       SetIndexBuffer(3,SpanB_Buffer);
       SetIndexDrawBegin(3,Kijun+Senkou-1);
       SetIndexShift(3,Kijun);
       SetIndexLabel(3,NULL);
       SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
       SetIndexBuffer(6,SpanB2_Buffer);
       SetIndexDrawBegin(6,Kijun+Senkou-1);
       SetIndexShift(6,Kijun);
       SetIndexLabel(6,"Senkou Span B");
    //----
       SetIndexStyle(4,DRAW_LINE);
       SetIndexBuffer(4,Chikou_Buffer);
       SetIndexShift(4,-Kijun);
       SetIndexLabel(4,"Chikou Span");
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Ichimoku Kinko Hyo                                               |
    //+------------------------------------------------------------------+
    int start()
      {
       int    i,k;
       int    counted_bars=IndicatorCounted();
       double high,low,price;
    //----
       if(Bars<=Tenkan || Bars<=Kijun || Bars<=Senkou) return(0);
    //---- initial zero
       if(counted_bars<1)
         {
          for(i=1;i<=Tenkan;i++)    Tenkan_Buffer[Bars-i]=0;
          for(i=1;i<=Kijun;i++)     Kijun_Buffer[Bars-i]=0;
          for(i=1;i<=a_begin;i++) { SpanA_Buffer[Bars-i]=0; SpanA2_Buffer[Bars-i]=0; }
          for(i=1;i<=Senkou;i++)  { SpanB_Buffer[Bars-i]=0; SpanB2_Buffer[Bars-i]=0; }
         }
    //---- Tenkan Sen
       i=Bars-Tenkan;
       if(counted_bars>Tenkan) i=Bars-counted_bars-1;
       while(i>=0)
         {
          high=High[i]; low=Low[i]; k=i-1+Tenkan;
          while(k>=i)
            {
             price=High[k];
             if(high<price) high=price;
             price=Low[k];
             if(low>price)  low=price;
             k--;
            }
          Tenkan_Buffer[i]=(high+low)/2;
          i--;
         }
    //---- Kijun Sen
       i=Bars-Kijun;
       if(counted_bars>Kijun) i=Bars-counted_bars-1;
       while(i>=0)
         {
          high=High[i]; low=Low[i]; k=i-1+Kijun;
          while(k>=i)
            {
             price=High[k];
             if(high<price) high=price;
             price=Low[k];
             if(low>price)  low=price;
             k--;
            }
          Kijun_Buffer[i]=(high+low)/2;
          i--;
         }
    //---- Senkou Span A
       i=Bars-a_begin+1;
       if(counted_bars>a_begin-1) i=Bars-counted_bars-1;
       while(i>=0)
         {
          price=(Kijun_Buffer[i]+Tenkan_Buffer[i])/2;
          SpanA_Buffer[i]=price;
          SpanA2_Buffer[i]=price;
          i--;
         }
    //---- Senkou Span B
       i=Bars-Senkou;
       if(counted_bars>Senkou) i=Bars-counted_bars-1;
       while(i>=0)
         {
          high=High[i]; low=Low[i]; k=i-1+Senkou;
          while(k>=i)
            {
             price=High[k];
             if(high<price) high=price;
             price=Low[k];
             if(low>price)  low=price;
             k--;
            }
          price=(high+low)/2;
          SpanB_Buffer[i]=price;
          SpanB2_Buffer[i]=price;
          i--;
         }
    //---- Chikou Span
       i=Bars-1;
       if(counted_bars>1) i=Bars-counted_bars-1;
       while(i>=0) { Chikou_Buffer[i]=Close[i]; i--; }
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    Código PHP:



    //+------------------------------------------------------------------+

    //| Caroline's Ichimoku Kinko Hyo.mq4 |

    //| Copyright 2013, MetaQuotes Software Corp. |

    //| http://www.metaquotes.net |

    //+------------------------------------------------------------------+

    #property copyright "Copyright 2013, MetaQuotes Software Corp."

    #property link "http://www.metaquotes.net"




    extern double Lots 0.1// Amount of lots to trade with

    extern double TakeProfit 0// The requested close price that determines the maximum profit for the given trade

    extern double TrailingStop 0// Min number of pips in profit for the trailing stop to start

    extern double StopLoss 0// The requested close price that determines the maximum loss allowed for the given trade

    extern double TenkanSen 9// Tenkan-sen (highest high + lowest low)/2 for the last 9 periods

    extern double KijunSen 26// Kijun-sen (highest high + lowest low)/2 for the past 26 periods




    //+------------------------------------------------------------------+

    //| expert initialization function |

    //+------------------------------------------------------------------+

    int init()

    {

    Alert ("Function init() triggered at start"); // Alert Initialization

    //----


    //----

    return(0); // Exit Initialization

    }

    //+------------------------------------------------------------------+

    //| expert start function |

    //+------------------------------------------------------------------+

    int start()

    {

    double TenkanSen;

    double KijunSen;

    int cnttickettotal;

    TenkanSen=iIchimoku(NULL092652MODE_TENKANSEN0);

    KijunSen=iIchimoku(NULL092652MODE_KIJUNSEN0);

    totalOrdersTotal();

    //----

    if(total<&& TenkanSen>KijunSen)

    {

    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,NULL,0,0,Green);

    }

    if(
    total<&& TenkanSen<KijunSen)

    {

    ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,NULL,0,0,Red);

    }

    //----

    if(total>&& TenkanSen==KijunSen && OrderType()==OP_BUY)

    {

    ticket=OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);

    }

    if(
    total>&& TenkanSen==KijunSen && OrderType()==OP_SELL)

    {

    ticket=OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue);

    }

    return(
    0);

    }

    //+------------------------------------------------------------------+

    //| expert deinitialization function |

    //+------------------------------------------------------------------+

    int deinit()

    {

    Alert ("Function deinit() triggered at exit"); // Alert Deinitialization

    //----


    //----

    return(0); // Exit Deinitialization

    }

    //+------------------------------------------------------------------+ 
    Más información sobre el tema: https://www.efxto.com/articulos-fore...ko-hyo-a-fondo
    Última edición por mitainvest; 22/04/2015 a las 16:55

Información de tema

Usuarios viendo este tema

Actualmente hay 1 usuarios viendo este tema. (0 miembros y 1 visitantes)

Marcadores

Permisos de publicación

  • No puedes crear nuevos temas
  • No puedes responder temas
  • No puedes subir archivos adjuntos
  • No puedes editar tus mensajes
  •