Re: Coding Help

1161
Hi mrtools and all them coders out here,

Im stuck with getting values in the EA from the indicator "waddah attar explosion averages nmc alerts 2_2.ex4" through iCustom() .
I did this before with others was not a big deal.
Here it just getting values on first bar and then just freezes... and values not changing while EA running...

I checked if i could iCustom() the same but renamed indicator in the main indicator, and comment its values... it worked...

Indicator and code is attached.Help me please!!!

Sincerely,
Sergei

Code: Select all

double one = iCustom(NULL,0,"waddah attar explosion averages nmc alerts 2_2.ex4",0,0);
double two = iCustom(NULL,0,"waddah attar explosion averages nmc alerts 2_2.ex4",1,0);

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  }

void OnTick()
  {
Comment(one, "  ", two);   
  }

Sincerely,
Sergei



QuestionRe: Coding Help

1162
Guys, I'm new to mql4.
I would like to write the code below in a different way. less amateur we can say.

I need the metatrader to calculate the number of closed candles with the high lower than the current candle.

As I do today:

Code: Select all

enum ENUM 
 {
   Var0,// 1 bar
   Var1,// 2 bars
   Var2,// 3 bars
   Var3,// 4 bars
   Var4,// 5 bars
 };

//---

input ENUM Bars = Var0;

//---

if(Bars==0)
  {
     if( High[i] > High[1+i] )
  }

if(Bars==1)
  {
     if( High[i] > High[1+i]
      && High[i] > High[2+i] )
  }

if(Bars==2)
  {
     if( High[i] > High[1+i]
      && High[i] > High[2+i]
      && High[i] > High[3+i])
  }

if(Bars==3)
  {
     if( High[i] > High[1+i]
      && High[i] > High[2+i]
      && High[i] > High[3+i]
      && High[i] > High[4+i] )
  }

if(Bars==4)
  {
     if( High[i] > High[1+i]
      && High[i] > High[2+i]
      && High[i] > High[3+i]
      && High[i] > High[4+i]
      && High[i] > High[5+i] )
  }

How could I create a function or variable to declare the number of closed candles to be calculated without having to use ENUM?

I thank you in advance for any kind of help and I'm sorry for my lack of knowledge, I'm working to write more optimized codes as I progress in my studies.

Re: Coding Help

1163
Dear Coders,

Request your help for the code to open a Sell trades if any of the following two conditions are met:

1) if last three candle have Red (sell volume) greater than Green (Buy volume). Buy trade will be opposite of this.
2) if three out of last 5 candle closures have Red (sell volume) greater than Green (Buy volume). Buy trade will be opposite of this

Attaching the screenshot for the indicator and buffer values..

Would like to use this in a EA..

Thanks for all your help...
Attachments

coding

1165
Greetings traders,i need help with something..provided that i dont know how to make a custom indicator i would get help here.I wanted to make a MACD oscillator edited there and there which had allerts and arrows for trend.i have realised that when i add moving average on 14 period almost 75% when it crosses over the MACD it goes with the trend perfectly

MACD fast EMA=12
slow EMA=24
MACD sma=1
colour of main=dim grey
colour of signal=DarkTurquoise

moving average=14
colour=lime
Attachments
These users thanked the author Mukhari325 for the post:
Narkarn


Re: Coding Help

1166
I'm building an EA to trade gold, but the lot size's keep causing the EA to error out. I'm trying to trade with 2 pct risk and 68 pip stop loss. But when the EA runs through Strategy Tester with a $50,000 account balance.

Code: Select all

 void OrderSize()
 {   
   string Pair="XAUUSD";
   double Risk_PCT =.02;
   double SL_PIPS=.68;
   double Tickval = MarketInfo( Pair, MODE_TICKVALUE );
   double bal=0;
   double Risk=0;
   int digits = MarketInfo( Pair, MODE_DIGITS);
   //---
   double Min_Lot=MarketInfo( Pair, MODE_MINLOT );
   double Max_Lot=MarketInfo( Pair, MODE_MAXLOT );
   double LEVERAGE = AccountLeverage();
   //---
   if((digits==3) || (digits==5))
     {
      Tickval*=10;
     }
   sl_num=SL_PIPS;     

   if(digits==5)
      sl_num=SL_PIPS*10000;
   if(digits==4)
      sl_num=SL_PIPS*1000;
   if(digits==3  || digits==2)
      sl_num=SL_PIPS*100;
   
   if( AccountFreeMargin()<AccountBalance() )                  //If Free margin less than account balance then 
     {
      Risk=AccountFreeMargin()*Risk_PCT;                           //use Free margin to calculate amount to risk
     }
   else                                                        //Else
     {
      Risk=AccountBalance()*Risk_PCT;                          //Update risk based on Account balance
     }
double lot_size;
   lot_size=(Risk)/(sl_num*Tickval);
   lot_size=MathRound(lot_size/MarketInfo(Pair, MODE_LOTSTEP))*MarketInfo(Pair, MODE_LOTSTEP);
   lot_size=NormalizeDouble(lot_size, digits);
   }
   

Re: Coding Help

1167
Hi, Awesome Coders,
I need One Help,
i tried To Add Automatic Higher Time frame Code to Heikin ashi Candle Count Indicator..! ( Copied Code From Other Indicator ).
it is working But When I Switch Between Timeframes It Takes More time ( Freezing for More than 30 Seconds )..!
i'm not a coder.. but Learner..!
can any coder Help Me Please..!
Thank you so much..!

Re: Coding Help

1168
Hi all,

I'm working on an indicator to aid back testing which will output a CSV file of my results. One of the things I want to add are the formulas for Excel, so that when I open the file up in Excel, all the totals I need will already be there.

However, I am having problems trying to output a comma (,) as a character in the csv file, without Excel thinking its a start of a new column. I know I can change the separator to something other than a comma, but don't really want to do that if I can help it as it requires extra steps in Excel to open the file.

This is the type of formula I want to use : =COUNTIF(C2:C9999,">0")

I've used the esc character for the double quotes \" and thought it would be the same for a comma, but sadly, this does not seem to work. Can this be done ?

My code is similar to this below :

filehandle=FileOpen(currentfilename,FILE_WRITE|FILE_CSV,",");
FileWrite(filehandle, "Wins:","=COUNTIF(L1:L9999\,\">0\")");

Any help would be appreciated !!

Re: Coding Help

1169
I have been modifying an indicator but can't get one thing to work, and respectfully requesting assistance. I took a Volatility Band indicator and modified it to have seperate inputs for the upper and lower bands and added the color change depending on being above or below the bands. I have been testing it out in this way: I look at this Vol_Band and if the bar is over the upper band NO TRADE and if it's under the lower band then take a half risk position. Also testing a pull back, if the candle closed with a red volatility bar, no trade but if the next candle closes at a better price and everything still says go and the vol_band is green go for it. Anyway what I am having trouble with is, I am trying to get the MA for the bands to not calculate the current candle, so each bar is compared to the ma of x number of days before and not including that bar. I get large bars that should be outside the band but the MA includes that bar in its calulation and keeps the bar inside. Hope this makes sense. ...... Solved...BandShift, thank you


Who is online

Users browsing this forum: Amazon [Bot], Seznam [Bot] and 18 guests