Like Tree4Likes

Thread: Momentum candle open to close price, please help me create this thanks



Page 1 of 2 12 LastLast

  1. #1
    Join Date
    Jan 2011
    Posts
    86
    Points
    276
    Credits
    725
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Momentum candle open to close price, please help me create this thanks

    Hi,

    when it comes to trading forex, we want to look for momentum to show us that the pair we are intrested in has any potential movement , I have been all over the internet looking for this simple indicator to show me when the candle has moved from the open price to the close price a certain amount of pips, I would like this candle to change colour, so lets say the price is just going sideways and we have no real momentum for what my setting is, say my setting was 15 pips on the 1 hour chart, so the open to close price was only around 8-10 pips , this would mean that the candles would remain with no colour on them, but as soon as the open to close price hits 15 pips or > than this, the candle would be painted green for and up candle or red for a down candle according to the minimum pip value that I have set it to.

    this would be a great visual indicator, and would save me from trying to work out the candles body size , all i need to do is look visualy at the candle for my momentum trigger.

    can someone please help me to create this indicator as i feel it would be a great help not only to me but to other people who have been searching for this.

    thanks
    Last edited by jamesagnew717; 01-04-2013 at 07:01 AM. Reason: spelling error

  2. #2
    cja's Avatar
    cja is offline Senior Member
    Join Date
    Apr 2006
    Posts
    990
    Points
    1,710
    Credits
    6,389
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    7
    Following
    0
    Follow

    Momentum candles

    Trade what you see not what you hope
    http://cjatradingtools.com/

  3. Thanks Val08 thanked for this post
    Likes Val08 liked this post
  4. #3
    Join Date
    Jan 2011
    Posts
    86
    Points
    276
    Credits
    725
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Big massive thank you my friend

    Quote Originally Posted by cja View Post

    Thank you so much for this great indicator, I hope that other people get good use of it also

    an mt5 version would be fantastic if you can do it


  5. #4
    tito_xs's Avatar
    tito_xs is offline Senior Member
    Join Date
    Aug 2012
    Posts
    105
    Points
    273
    Credits
    124
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow
    Quote Originally Posted by cja View Post
    nice work

  6. #5
    cja's Avatar
    cja is offline Senior Member
    Join Date
    Apr 2006
    Posts
    990
    Points
    1,710
    Credits
    6,389
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    7
    Following
    0
    Follow

    Momentum candles MT5

    I have not done much in the way of MT5 code but I have managed to get this to work ( see screenshot below ), however either my windows 7 or MT5 is stopping me gaining access to the custom indicator files so i have to post it like this. Hopefully this will work for you.

    Code:
    //+------------------------------------------------------------------+
    //|                                             Momentum candles.mq5 |
    //|                                                           by cja |
    //+------------------------------------------------------------------+
    #property copyright "Copyright 2013, MetaQuotes Software Corp."
    #property link      "MQL5: automated forex trading, strategy tester and custom indicators with MetaTrader"
    #property version   "1.00"
    #property indicator_chart_window
    #property indicator_buffers 5
    #property indicator_plots   1
    #property indicator_type1   DRAW_COLOR_CANDLES
    #property indicator_color1  Green,Red,Gray
    #property indicator_width1  3
    #property indicator_label1  "Momentum Candles"
    input int   CandlePipValue         = 10;              
    //--- indicator buffers
    double ExtOBuffer[];
    double ExtHBuffer[];
    double ExtLBuffer[];
    double ExtCBuffer[];
    double ExtColorBuffer[];
    //--- handles of indicators
    //--- bars minimum for calculation
    #define DATA_LIMIT 38
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    void OnInit()
      {
    //--- indicator buffers mapping
       SetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA);
       SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA);
       SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA);
       SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA);
       SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX);
      //---
       IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
    //--- sets first bar from what index will be drawn
       IndicatorSetString(INDICATOR_SHORTNAME,"Momentum Candles");
    //--- don't show indicator data in DataWindow
       PlotIndexSetInteger(0,PLOT_SHOW_DATA,false);
    //--- sets first candle from what index will be drawn
       PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,DATA_LIMIT);
    //--- get handles
      
    //--- initialization done
      }
    int OnCalculate(const int rates_total,
                    const int prev_calculated,
                    const datetime &Time[],
                    const double &Open[],
                    const double &High[],
                    const double &Low[],
                    const double &Close[],
                    const long &TickVolume[],
                    const long &Volume[],
                    const int &Spread[])
      {
       int i,limit;
      
    //--- we can copy not all data
       int to_copy;
       if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;
       else
         {
          to_copy=rates_total-prev_calculated;
          if(prev_calculated>0) to_copy++;
         }
    //--- set first bar from what calculation will start
       if(prev_calculated<DATA_LIMIT)
          limit=DATA_LIMIT;
       else
          limit=prev_calculated-1;
          
       double pipModifier=1;
          if (_Digits==3 || _Digits==5) pipModifier=10;
    //--- the main loop of calculations
       for(i=limit;i<rates_total && !IsStopped();i++)
         {
          ExtOBuffer[i]=Open[i];
          ExtHBuffer[i]=High[i];
          ExtLBuffer[i]=Low[i];
          ExtCBuffer[i]=Close[i];
          //--- set color for candle
          ExtColorBuffer[i]=2.0;  // set gray Color
          //--- check for Green Zone and set Color Green
           if(Open[i]>Close[i] && (Open[i]-Close[i])>=CandlePipValue*_Point*pipModifier)
             ExtColorBuffer[i]=1.0;
          //--- check for Red Zone and set Color Red
          if(Open[i]<Close[i] && (Close[i]-Open[i])>=CandlePipValue*_Point*pipModifier)
             ExtColorBuffer[i]=0.0;
         }
    //--- return value of prev_calculated for next call
       return(rates_total);
      }
    //+------------------------------------------------------------------+

    Click image for larger version. 

Name:	Momentum Candles.gif 
Views:	536 
Size:	16.5 KB 
ID:	148966
    Trade what you see not what you hope
    http://cjatradingtools.com/

  7. #6
    Join Date
    Jan 2011
    Posts
    86
    Points
    276
    Credits
    725
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Meta Trader 5 code working great thank you again !!!

    Quote Originally Posted by cja View Post
    I have not done much in the way of MT5 code but I have managed to get this to work ( see screenshot below ), however either my windows 7 or MT5 is stopping me gaining access to the custom indicator files so i have to post it like this. Hopefully this will work for you.

    Code:
    //+------------------------------------------------------------------+
    //|                                             Momentum candles.mq5 |
    //|                                                           by cja |
    //+------------------------------------------------------------------+
    #property copyright "Copyright 2013, MetaQuotes Software Corp."
    #property link      "MQL5: automated forex trading, strategy tester and custom indicators with MetaTrader"
    #property version   "1.00"
    #property indicator_chart_window
    #property indicator_buffers 5
    #property indicator_plots   1
    #property indicator_type1   DRAW_COLOR_CANDLES
    #property indicator_color1  Green,Red,Gray
    #property indicator_width1  3
    #property indicator_label1  "Momentum Candles"
    input int   CandlePipValue         = 10;              
    //--- indicator buffers
    double ExtOBuffer[];
    double ExtHBuffer[];
    double ExtLBuffer[];
    double ExtCBuffer[];
    double ExtColorBuffer[];
    //--- handles of indicators
    //--- bars minimum for calculation
    #define DATA_LIMIT 38
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    void OnInit()
      {
    //--- indicator buffers mapping
       SetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA);
       SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA);
       SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA);
       SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA);
       SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX);
      //---
       IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
    //--- sets first bar from what index will be drawn
       IndicatorSetString(INDICATOR_SHORTNAME,"Momentum Candles");
    //--- don't show indicator data in DataWindow
       PlotIndexSetInteger(0,PLOT_SHOW_DATA,false);
    //--- sets first candle from what index will be drawn
       PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,DATA_LIMIT);
    //--- get handles
      
    //--- initialization done
      }
    int OnCalculate(const int rates_total,
                    const int prev_calculated,
                    const datetime &Time[],
                    const double &Open[],
                    const double &High[],
                    const double &Low[],
                    const double &Close[],
                    const long &TickVolume[],
                    const long &Volume[],
                    const int &Spread[])
      {
       int i,limit;
      
    //--- we can copy not all data
       int to_copy;
       if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;
       else
         {
          to_copy=rates_total-prev_calculated;
          if(prev_calculated>0) to_copy++;
         }
    //--- set first bar from what calculation will start
       if(prev_calculated<DATA_LIMIT)
          limit=DATA_LIMIT;
       else
          limit=prev_calculated-1;
          
       double pipModifier=1;
          if (_Digits==3 || _Digits==5) pipModifier=10;
    //--- the main loop of calculations
       for(i=limit;i<rates_total && !IsStopped();i++)
         {
          ExtOBuffer[i]=Open[i];
          ExtHBuffer[i]=High[i];
          ExtLBuffer[i]=Low[i];
          ExtCBuffer[i]=Close[i];
          //--- set color for candle
          ExtColorBuffer[i]=2.0;  // set gray Color
          //--- check for Green Zone and set Color Green
           if(Open[i]>Close[i] && (Open[i]-Close[i])>=CandlePipValue*_Point*pipModifier)
             ExtColorBuffer[i]=1.0;
          //--- check for Red Zone and set Color Red
          if(Open[i]<Close[i] && (Close[i]-Open[i])>=CandlePipValue*_Point*pipModifier)
             ExtColorBuffer[i]=0.0;
         }
    //--- return value of prev_calculated for next call
       return(rates_total);
      }
    //+------------------------------------------------------------------+

    Click image for larger version. 

Name:	Momentum Candles.gif 
Views:	536 
Size:	16.5 KB 
ID:	148966


    Thank you for your quick response to this, I got the MT5 indicator working

    just brilliant




  8. #7
    cja's Avatar
    cja is offline Senior Member
    Join Date
    Apr 2006
    Posts
    990
    Points
    1,710
    Credits
    6,389
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    7
    Following
    0
    Follow

    Candle colors

    I forgot to mention if you want to display the no signal candles as normal MT5 candles replace line 12 with
    Code:
    #property indicator_color1  Green,Red,CLR_NONE
    Click image for larger version. 

Name:	mom.gif 
Views:	169 
Size:	17.3 KB 
ID:	148999
    Trade what you see not what you hope
    http://cjatradingtools.com/

  9. #8
    winner246 is offline Senior Member
    Join Date
    Oct 2009
    Posts
    331
    Points
    639
    Credits
    832
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Momentum candles 2

    HELLO CJA,

    Thanks for your skillful contributions.

    I have been using the momentum candles and i have found out the momentum signals can be filtered to reduce some of the false signals by ADDING a 2nd rule based on pips difference between the LOW AND HIGH.

    Can you please create this new version based on these rules ;

    FOR GREEN CANDLE ;

    (1) CLOSE IS ABOVE OPEN BY ...........X PIPS, and
    (2) HIGH IS ABOVE LOW BY ...........X PIPS

    FOR RED CANDLE ;

    (1) CLOSE IS BELOW OPEN BY .......... X PIPS, and
    (2) LOW IS BELOW HIGH BY ......... X PIPS

    THANKS IN ADVANCE FOR YOUR ANTICIPATED RESPONSE.

  10. #9
    cja's Avatar
    cja is offline Senior Member
    Join Date
    Apr 2006
    Posts
    990
    Points
    1,710
    Credits
    6,389
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    7
    Following
    0
    Follow

    Added High Low option

    Try these, the MQL4 should be good and the MQL5 should be alright but I have not done enough MQL5 code to be sure.

    If you want the indicators to give the same signals as the previous versions just set the High low pip value to smaller than the Candle pip value.

    Momentum candles v1.mq5
    Momentum Candles v1.mq4
    Trade what you see not what you hope
    http://cjatradingtools.com/

  11. Thanks Val08 thanked for this post
    Likes Val08 liked this post
  12. #10
    winner246 is offline Senior Member
    Join Date
    Oct 2009
    Posts
    331
    Points
    639
    Credits
    832
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Mom candles 2

    Hello cja,

    thank you very much for your prompt response.

» Rankings



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Please help to find this expert.
    By savio in forum Metatrader 4
    Replies: 5
    Last Post: 06-06-2007, 02:56 PM
  2. please help me improve this EA
    By iPlayGames in forum Metatrader 4
    Replies: 0
    Last Post: 12-13-2006, 09:39 AM
  3. Please help to make this mt4 indicator
    By jacoba in forum Metatrader 4
    Replies: 4
    Last Post: 02-13-2006, 04:24 PM
  4. Static variable problem - Please help
    By cardio in forum MetaTrader Programming
    Replies: 2
    Last Post: 11-09-2005, 11:45 AM
  5. Static variable problem - Please help
    By cardio in forum Metatrader 4
    Replies: 1
    Last Post: 11-08-2005, 06:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •