How to code? - page 165

 

Thank you

sometime the solution is so simple.....

 

How do you add a comment to show how many Buy and sell position are open at any time on a pair by pair basis.

double Buy.cm = MarketInfo(Symbol(),MODE_TRADES); ??? buy

double Sell.cm = MarketInfo(Symbol(),MODE_TRADES); ??? sell

Cheers

Beno

 

If you have a function that counts orders just adapt it to have a counter variable for buys and sells. Then write a comment as normal.

Lux

 
luxinterior:
If you have a function that counts orders just adapt it to have a counter variable for buys and sells. Then write a comment as normal. Lux

ok thanks lux

 
Beno:
How do you add a comment to show how many Buy and sell position are open at any time on a pair by pair basis.

double Buy.cm = MarketInfo(Symbol(),MODE_TRADES); ??? buy

double Sell.cm = MarketInfo(Symbol(),MODE_TRADES); ??? sell

Cheers

Beno

You could do something like this:

int Open_Trades = OrdersTotal();

int Pos=0;

int Buy_Total=0;

int Sell_Total=0;

while (Open_Trades > Pos)

{

if (OrderSelect(Pos,SELECT_BY_POS,MODE_TRADES))

{

int Order_Type = OrderType();

if (Order_Type == OP_BUY)

{

Buy_Total++;

}

if (Order_Type == OP_SELL)

{

Sell_Total++;

}

}

Pos++;

}

Comment("\nBuy Orders Total = ",Buy_Total,

"\nSell Orders Total = ",Sell_Total);

Or some variation.

Files:
 

Indicator needs to reference Bollinger Bands

I have this indicator, however, I need it to reference the Bollinger Bands. I need it to include reference to at or near the Bollinger and inside candle. Would like to reference Stochastics too. Any ideas.

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

//| MS IPP2 v2 3/6/09 |

//| MarketSlayer |

//| BillTainter@gmail.com |

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

#property copyright " MarketSlayer "

#property link "BillTainter@gmail.com"

#property indicator_chart_window

//---- input parameters

extern int barsToProcess=1000;

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

//| Custom indicator initialization function |

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

int init ()

{

//---- indicators

//----

return (0);

}

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

//| Custom indicator deinitialization function |

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

int deinit ()

{

//----

int i;

for (i=0; i< Bars; i++)

{

ObjectDelete ("Bearish IPP2" +DoubleToStr (i, 0));

ObjectDelete ("Bullish IPP2" +DoubleToStr (i, 0));

}

//----

return (0);

}

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

//| Custom indicator iteration function |

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

int start ()

{

int counted_bars=IndicatorCounted (),

//----

limit,

i=0;

if (counted_bars> 0)

counted_bars--;

limit=Bars-counted_bars;

if (limit> barsToProcess)

limit=barsToProcess;

while (i< limit)

{

// BEARISH IPP#2

// Candle[1] is at or near Top Bollinger Band

// Candle[2] is inside Candle[1]

if ((Close [ i+2] > Open [ i+2]) && (Close [ i+1]> Open ) && (Open > Close [ i+1])

&& (High Low [ i+1]))

{

ObjectCreate ("Bearish IPP2" +DoubleToStr (i, 0), OBJ_ARROW, 0, Time , High + 50*Point);

ObjectSet ("Bearish IPP2" +DoubleToStr (i, 0), OBJPROP_ARROWCODE, 130);

ObjectSet ("Bearish IPP2" +DoubleToStr (i, 0), OBJPROP_COLOR, Red );

Alert("Bearish IPP2 -SHORT @", Low);

}

// Bullish IPP#2

if ((Close [ i+2] < Open [ i+2]) && (Close [ i+1]< Open ) && (Open < Close [ i+1])

&& (High Low [ i+1]))

{

ObjectCreate ("Bullish IPP2" +DoubleToStr (i, 0), OBJ_ARROW, 0, Time , Low - 50*Point);

ObjectSet ("Bullish IPP2" +DoubleToStr (i, 0), OBJPROP_ARROWCODE, 130);

ObjectSet ("Bullish IPP2" +DoubleToStr (i, 0), OBJPROP_COLOR, Lime );

Alert("Bullish IPP2 -LONG @", High,Time);

// PlaySound("alert.wav");

}

i++;

}

//----

return (0);

}

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

 

is there any way to check if the last order was closed by reaching tp, sl or without hitting one of them?

Greetings

 

Could someone help me add a audible alert to this indicator??

Thank you!

Files:
hilow3.mq4  2 kb
 
jan100:
is there any way to check if the last order was closed by reaching tp, sl or without hitting one of them? Greetings

If OrderClosePrice() equal OrderStopLoss() order was closed by reaching sl.

 

Conversion of Indicator into EA

Hi All,

I got an issue with the EA of RSI and MA...

I got the indicator working properly... All I want is to convert it into EA...

I tried a couple of things. IndicatorCounted() is not working in EA, so I tried to hard-code the values of the for loop (bar=0; bar<15; bar++), I was getting correct RSI, but SMA is not giving corect values...

I'm attaching the code for SMA crossing the RSI...

So could someone please help me to convert this Indicator into EA.

***************************************************************************************************************************************

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 LawnGreen

#property indicator_color2 DarkBlue

double ExtMapBuffer1[];

double ExtMapBuffer2[];

int init()

{

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);

SetIndexBuffer(1,ExtMapBuffer2);

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int bar, limit;

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit=Bars-IndicatorCounted();

for(bar=0; bar<limit; bar++)

ExtMapBuffer1 = iRSI(NULL,0,14,PRICE_TYPICAL,bar);

for(bar=0; bar<limit; bar++)

ExtMapBuffer2=iMAOnArray(ExtMapBuffer1,Bars,14,0,MODE_SMA,bar);

return(0);

}

***************************************************************************************************************************************

Thanks & Regards,

Ganesh

Reason: