Coding help - page 628

 
annbeea:
Thanks

but i am quite a newbie to coding

can i change to if a mt4 named xyz indicator has following parameters:

extern int A=9;

extern int B=14;

extern int D = 10;

and icustom part asE= iCustom(Null,timeframe,"xyz",A,B,D,BufferNumber,Shift); ?but i do not much understand BufferNumber and Shift? what does that means? thanks

annbee

Check this thread for details : https://www.mql5.com/en/forum/173108

 

hi mladen,

may be i think i made some mistakes previously,

xyz should be like this:

extern int A=9;

extern int B=14;

extern double D = 10;

question1:and icustom part asE= iCustom(Null,timeframe,"xyz",A,B,D,0,pos); is it ok/ correct?? thanks

question2:and icustom part asE= iCustom(Null,timeframe,"xyz",A,B,0,pos); how about if i intentionally or mistakenly miss out the D in icustom sentence, is it ok work or missing something in display or calculation or total incorrect? thanks for comments.

 
annbeea:
hi mladen,

may be i think i made some mistakes previously,

xyz should be like this:

extern int A=9;

extern int B=14;

extern double D = 10;

question1:and icustom part asE= iCustom(Null,timeframe,"xyz",A,B,D,0,pos); is it ok/ correct?? thanks

question2:and icustom part asE= iCustom(Null,timeframe,"xyz",A,B,0,pos); how about if i intentionally or mistakenly miss out the D in icustom sentence, is it ok work or missing something in display or calculation or total incorrect? thanks for comments.

If you omit one parameter from the tail of the parameters list, default value for parameter will be used, but please read that thread for details how is iCustom() function used and what are the exact parameters for iCustom() function

 

hi mladen

my coding level is very low because i just has very raw computing learning before, i just want to make something work for me without too sophiscated coding, most things i am not very understand even read the thread ,

because i even not clear the difference between concept of double, string, etc.

but my question is just that, it seems the key here is D, so my question is: is it whether : extern int D=10 or extern double D=10 ,icustom part asE= iCustom(Null,timeframe,"xyz",A,B,D,0,pos); is it ok/ correct?? thanks

 
annbeea:

hi mladen

my coding level is very low because i just has very raw computing learning before, i just want to make something work for me without too sophiscated coding, most things i am not very understand even read the thread ,

because i even not clear the difference between concept of double, string, etc.

but my question is just that, it seems the key here is D, so my question is: is it whether : extern int D=10 or extern double D=10 ,icustom part asE= iCustom(Null,timeframe,"xyz",A,B,D,0,pos); is it ok/ correct?? thanks

anbbeea,

Yes, that is correct

 

Hello Mladen ,

May i know about the ray on chart can be adjust how long to the right side that i want ?

How to change this >

ObjectSet("mMyLine", OBJPROP_RAY, false);
extern color mCol = Red, mCol2 = Blue, mCol3 = White;
extern int mWid = 2, mHist = 100, mDays = 5;

//+------------------------------------------------------------------+
int init()
  {
      ObjectCreate("mMyLine", OBJ_TREND, 0, 0, 0, 0, 0);
      ObjectSet("mMyLine", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("mMyLine", OBJPROP_TIME1, Time[mHist]);
      ObjectSet("mMyLine", OBJPROP_TIME2, Time[0]);
      ObjectSet("mMyLine", OBJPROP_WIDTH, mWid);
      ObjectSet("mMyLine", OBJPROP_COLOR, mCol);
      ObjectSet("mMyLine", OBJPROP_RAY, false);

      ObjectCreate("mMyLine2", OBJ_TREND, 0, 0, 0, 0, 0);
      ObjectSet("mMyLine2", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("mMyLine2", OBJPROP_TIME1, Time[mHist]);
      ObjectSet("mMyLine2", OBJPROP_TIME2, Time[0]);
      ObjectSet("mMyLine2", OBJPROP_WIDTH, mWid);
      ObjectSet("mMyLine2", OBJPROP_COLOR, mCol2);
      ObjectSet("mMyLine2", OBJPROP_RAY, false);
      
      ObjectCreate("mMyLine3", OBJ_TREND, 0, 0, 0, 0, 0);
      ObjectSet("mMyLine3", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("mMyLine3", OBJPROP_TIME1, Time[mHist]);
      ObjectSet("mMyLine3", OBJPROP_TIME2, Time[0]);
      ObjectSet("mMyLine3", OBJPROP_WIDTH, mWid);
      ObjectSet("mMyLine3", OBJPROP_COLOR, mCol3);
      ObjectSet("mMyLine3", OBJPROP_RAY, false);

   return(0);
  }

//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("mMyLine");
   ObjectDelete("mMyLine2");
   ObjectDelete("mMyLine3");
   return(0);
  }

//+------------------------------------------------------------------+
int start()
  {
   double mH = 0, mL=0, mM = 0;
   
   mH = iHigh(NULL, 1440, iHighest(NULL, 1440, MODE_HIGH, mDays, 1));
   mL = iLow(NULL, 1440, iLowest(NULL, 1440, MODE_LOW, mDays, 1));
   mM = mL + (mH - mL) / 2;
   ObjectSet("mMyLine", OBJPROP_PRICE1, mH);
   ObjectSet("mMyLine", OBJPROP_PRICE2, mH);
   ObjectSet("mMyLine2", OBJPROP_PRICE1, mL);
   ObjectSet("mMyLine2", OBJPROP_PRICE2, mL);
   ObjectSet("mMyLine3", OBJPROP_PRICE1, mM);
   ObjectSet("mMyLine3", OBJPROP_PRICE2, mM);


   return(0);
  }
 

please have tried to make the arrow appear after the close of the signal candle in other to avoid repainting but all to no avail.

please  help me out  MR. TOOLS and MLADEN, below are the attached.
 

mladen & mrtools

I have an EA that blast it self with trades. I need help to build a Void or function that can be added to an existing EA. This function needs to address:

input bool doBasketExit = true; // Check for Basket Exit conditions
input double BasketTP = 250.0; // Basket Take Profit (Account Currency) The chart Pair
input double BasketSL = -100.0; // Basket Stop Loss (Account Currency) The chart Pair

Im running 9 pairs/Charts with aggressive EA on the H1 and I want pair specific basket trading on each of the 9 charts.
Here's what just happened to me. 9 charts running, 3 charts are in trade with, of course, 3 separate pairs, each with 15 trades, yes 45 trades open, 2 are in profit & one is losing badly. I looking for a way to add up each group/pair of the 15 separately and rub each group against a Basket SL & TP boundaries. I found a basket set up but of course it needs refinement. The trick is to get the same pair added up from the Order Profit Trade column. By being on a Chart with a specific pair I thought I come up with a void but its kind of complicated. The function must somehow read the OrderProfit by Pair???

See my code as a poor example;

void closeTrades( CURRENCY* &currencies[] ) {
// Check for Basket Exit
if ( doBasketExit ) {
double basketProfit = getBasketProfit();
if ( ( ( BasketTP > 0.0 ) && ( basketProfit > BasketTP ) ) ||
( ( BasketSL < 0.0 ) && ( basketProfit < BasketSL ) ) ) {
closeAll();
}
}
double getBasketProfit() {
double basketProfit = 0.0;
for (int iOrder=OrdersTotal()-1; iOrder >= 0; iOrder--) {
if (OrderSelect(iOrder,SELECT_BY_POS,M ODE_TRADES)) {
if ( OrderMagicNumber() == MagicNumber ) {
if ( (OrderType() == OP_BUY) || (OrderType() == OP_SELL) ) {
basketProfit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
}
return(basketProfit);
}

void closeAll() {
double closePrice;
string symbolName;
int result;
for (int iOrder=OrdersTotal()-1; iOrder >= 0; iOrder--) {
if (OrderSelect(iOrder,SELECT_BY_POS,M ODE_TRADES)) {
if ( OrderMagicNumber() == MagicNumber ) {
if ( (OrderType() == OP_BUY) || (OrderType() == OP_SELL) ) {
symbolName = OrderSymbol();
closePrice = ( OrderType() == OP_BUY ) ? MarketInfo( symbolName, MODE_BID ) : MarketInfo( symbolName, MODE_ASK );
result = OrderCloseReliable(OrderTicket(), OrderLots(), closePrice, 50 );
}
}



Really appreciate you looking into this

Thanks
Ray

 
stevenpun:

Hello Mladen ,

May i know about the ray on chart can be adjust how long to the right side that i want ?

How to change this >

Try doing the following :

Instead of

ObjectSet("mMyLine", OBJPROP_TIME2, Time[0]);
//
//
//   try this
//   use the NumberOfDaysToTheRight for the number of days to extend it to the right
//   you have to update this in the start procedure on every tick and for every ray that you created
//
//

ObjectSet("mMyLine", OBJPROP_TIME2, Time[0]+PERIOD_D1*60*NumberOfDaysToTheRight);
 
kapoo:

please have tried to make the arrow appear after the close of the signal candle in other to avoid repainting but all to no avail.

please  help me out  MR. TOOLS and MLADEN, below are the attached.

kapoo

Currently uploads are not working so I can not see your files

As soon as those issues are solved, we shall resume. OK?

Reason: