Coding help - page 781

 
Please , Will you be willing to help?

I have this indicator it suppose to be updating some values at the close of candle, But it does not respond early enough ,usually 20 -40 sec after close of candle Many times I have to reload the Chart 

Can you assist to fix that?
Files:
 
Savior: r it suppose to be updating some values at the close of candle,

There is no such thing. A candle is considered closed, when a new tick arrives past the last second of the current candle starting a new candle.

There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific.) requires knowledge of when your broker stops and starts (not necessary the same as the market.)
          "Free-of-Holes" Charts - MQL4 Articles 20 June 2006
          No candle if open = close ? - MQL4 programming forum 2010.06.06

The code runs once per second on a timer and updates when one symbol starts a new bar. Nothing wrong.

 

Hello All -

Set up some decent EA's using EA Builder however am struggling to set one up using Fractals. 

Given fractals appear as mid-point in 5-candle series, i expect i may be getting the 'shift' & index incorrect. 

Trying to create a simple long (once i understand the shift/index i would be able to increase parameters)

Open, Fractal, Time Frame (Current), Indicator (Upper) Shift (3) 'is above' Candlestick, Index (3), Value (Low)

Idea being the fractal is below a low candle, ready to start up trend..realing that the most two current candles would have higher highs, i would use this as limit buy on pullback not below Fractal

Greatly appreciate the assistance! thank you, david

 
  1. David-Toronto: Greatly appreciate the assistance! thank you, david
    Help you with what? You haven't stated a problem, you haven't even stated a want?

  2. David-Toronto: Set up some decent EA's using EA Builder
    EA builder, EATree, Etasoft forex generator, Forex Strategy Builder, FOREXEADVISOR STRATEGY BUILDER, FX EA Builder, fxDreema, FxPro, Molanis, Online Forex Expert Advisor Generator, Strategy Builder FX, Strategy Quant, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.
    1. Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.
      We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    2. EA builder makes bad code counting up while closing multiple orders.
      EA builder makes bad code Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
      EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
      EA builder makes bad code, not adjusting for ECN brokers. pre-Build 500)
      EA builder makes bad code, not
      checking return codes.

    3. EATree uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)

    4. FX EA Builder makes bad code, not checking return codes.
      FX EA Builder makes bad code, loosing open tickets on terminal restart. No recovery (crash/power failure.)
      FX EA Builder makes bad code, not adjusting stops for the spread.
      FX EA Builder makes bad code, using OrdersTotal directly.

    5. FOREXEADVISOR STRATEGY BUILDER makes bad code, non-updateing global variables.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, compilation errors.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, not checking return codes.

    Learn to code it, or pay someone (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum

 
William Roeder:
  1. Help you with what? You haven't stated a problem, you haven't even stated a want?

  2. EA builder, EATree, Etasoft forex generator, Forex Strategy Builder, FOREXEADVISOR STRATEGY BUILDER, FX EA Builder, fxDreema, FxPro, Molanis, Online Forex Expert Advisor Generator, Strategy Builder FX, Strategy Quant, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.
    1. Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.
      We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    2. EA builder makes bad code counting up while closing multiple orders.
      EA builder makes bad code Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
      EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
      EA builder makes bad code, not adjusting for ECN brokers. pre-Build 500)
      EA builder makes bad code, not
      checking return codes.

    3. EATree uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)

    4. FX EA Builder makes bad code, not checking return codes.
      FX EA Builder makes bad code, loosing open tickets on terminal restart. No recovery (crash/power failure.)
      FX EA Builder makes bad code, not adjusting stops for the spread.
      FX EA Builder makes bad code, using OrdersTotal directly.

    5. FOREXEADVISOR STRATEGY BUILDER makes bad code, non-updateing global variables.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, compilation errors.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, not checking return codes.

    Learn to code it, or pay someone (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum

Thanks William, but not ready to code yet & don't need brick to the head. 

To someone who started or used EA Builder, please only reply if you can assist.  thanks


Question is how to open long trade (using EA Builder) for fractal occurring above candle.

My attempt is giving buy orders occurring after any fractal occurrence (above or below candle).     

 using:  Fractal, Time Frame (Current), Indicator (Upper) Shift (3) 'is above' Candlestick, Index (3), Value (Low)

 

Good afternoon

I'm pretty new to coding and would like some assistance on an indicator that I'm trying to code. I'm basically making my own MA a band of the open and close values of bars depending on which one is where, i.e. if open is higher than close, it is saved to the top array, else it is saved in the bottom array. I have done a fair bit of troubleshooting on an EA i wrote, but I cannot get the same result on the indicator, unfortunately.

Files:
MA_Band.mq4  5 kb
 
  1. PLZFrosty: but I cannot get the same result on the indicator,

    "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. You haven't stated a problem.

  2.       SetIndexBuffer(0, MA_top);
          ⋮
          SetIndexBuffer(1, MA_bot);
    
    How many buffers did you declare your indicator has? If you had checked your return codes, you would have known why.
              Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference
 
William Roeder:
  1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. You haven't stated a problem.

  2. How many buffers did you declare your indicator has? If you had checked your return codes, you would have known why.
              Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

I know what it is supposed to do, but I don't know how to find out why it isn't working. I've used the Comment function to figure out where it stops working and found that it stops at the point where it is supposed to put the values in the mentioned arrays. I'm asking for guidance on troubleshooting, not someone fixing it for me. Telling me what I missed or what I did wrong and where to read up for the solution will help me a lot. Thanks for the link. At least it is one of my problems solved. Is there a more efficient way than to use Comment() to troubleshoot where code bombed?

Documentation on MQL5: Common Functions / Comment
Documentation on MQL5: Common Functions / Comment
  • www.mql5.com
[in]   Any values, separated by commas. To delimit output information into several lines, a line break symbol "\n" or "\r\n" is used. Number of parameters cannot exceed 64. Total length of the input comment (including invisible symbols) cannot exceed 2045 characters (excess symbols will be cut out during output). Data of double type are output...
 
PLZFrosty:

I know what it is supposed to do, but I don't know how to find out why it isn't working. I've used the Comment function to figure out where it stops working and found that it stops at the point where it is supposed to put the values in the mentioned arrays. I'm asking for guidance on troubleshooting, not someone fixing it for me. Telling me what I missed or what I did wrong and where to read up for the solution will help me a lot. Thanks for the link. At least it is one of my problems solved. Is there a more efficient way than to use Comment() to troubleshoot where code bombed?

I somehow got it to work, but I have no idea why it is working and not the other way round. I saw a small mistake in my reasoning and rewrote the my function. It is still not showing me my array's values when I use Comment(DoubleToString(array[1], 3);, but it is at least drawing the MA line. Is there a way that I can see my array values other than using Comment()?
 
input int SmallEMA = 50;
input int BigEMA = 100;
void OnTick()
  {
   string signal = "";
   double SmallMovingAvarage1 = iMA(Symbol(),PERIOD_CURRENT,SmallEMA,0,MODE_EMA,PRICE_CLOSE,0);
   double BigMovingAvarage1   = iMA(Symbol(),PERIOD_CURRENT,BigEMA,0,MODE_EMA,PRICE_CLOSE,0);
   
   if (BigMovingAvarage1 > SmallMovingAvarage1)
   
   {
   
      signal = "sell";
   }
   
   if (BigMovingAvarage1 < SmallMovingAvarage1)
    
   {
      signal = "buy";
   }
   
   
 
   if (signal == "sell" &&   OrdersTotal() == 0 )
   
   OrderSend(Symbol(),OP_SELL,0.02,Bid,10,0,0,NULL,0,0);
   
    
   
   if ( signal == "buy" && OrdersTotal() == 1)
   
   CloseSellPositions();
  
   
   
   if (signal == "buy" &&  OrdersTotal() == 0  )
   
    OrderSend(Symbol(),OP_BUY,0.02,Ask,10,0,0,NULL,0,0);
   
   //if (signal == "sell" && 0 <= OrdersTotal() <= 1)
   
   if (signal == "sell" && OrdersTotal() == 0)
   
   CloseBuyPositions();
    
   
   Comment ("The current signal is: ",signal);
   
   
  }


void CloseBuyPositions()
   {
   
   for(int i = OrdersTotal() -1 ; i >= 1; i--)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      
      string CurrencyPair = OrderSymbol();
      
      if(Symbol() == CurrencyPair)
      
      if (OrderType () == OP_BUY)
      {
         
         OrderClose(OrderTicket(),0.02,Bid,10);
      }
   }
   
   
   }
void CloseSellPositions()
   {
   
   for(int i = OrdersTotal()- 1; i >= 1; i--)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      
      string CurrencyPair = OrderSymbol();
      
      if(Symbol() == CurrencyPair)
      
      if (OrderType () == OP_SELL)
      {
         OrderClose(OrderTicket(),0.02,Ask,10);
      }
    }
   } 

Hi,


EMA (1) = 50

EMA (2) = 100


if (50 <100)

Close open buy position if any and open a sell position


if (50> 100)


Close the open sell position, if any, and open buy positions.


I want to develop a specialist consultant that meets these conditions, I shared the code I wrote. But it doesn't work as I want.


Can you help me to complete the parts missing in my code?