How to code? - page 152

 
m_43_62:
hi

thanks very much all friends

You can not use indicator as a advisor, you have to use advisor with indicator, like this:

P.S. Don't forget put the indicator to indicator directory.

Files:
 

deleted

--- deleted ---

 

Code to show DAYS/HOURS since the last MA cross

I need a code that shows me the last time two MA's crossed (i.e. how long ago). It can show it in days or hours.

Any help would be appreciated!

Todd

 

Conversion to Market Execution

I have an EA built for the "Instant Execution" version of Metatrader4 and I need someone to change the code so it will work on a "Market Execution" version of Metatrader4. Please email me a quote or or any questions to phasna@gmail.com

Thanks

Paul

 

Does anyone know the icustom statement to use in an EA for this indicator?

It only has one buffer SetIndexBuffer( 0, TrStopLevel ); which is used for the trailing dots, the arrows are drawn by ObjectSet how do you pick that up in the icustom statement?

MT4-LevelStop-Reverse-v2-1.mq4

 
increase:
Does anyone know the icustom statement to use in an EA for this indicator?

It only has one buffer SetIndexBuffer( 0, TrStopLevel ); which is used for the trailing dots, the arrows are drawn by ObjectSet how do you pick that up in the icustom statement?

MT4-LevelStop-Reverse-v2-1.mq4

Is anyone out there for help?

 

Help me place trades in between the spreads!

Ok, spreads kill some pairs. but is theire away to place trades in the middle of a spreads. This way we can save pips and make more money. i have this code and can it be changed to modify the order to chart price not bid ask?

void PlaceBuyOrder()

{

double BuyOrders, Lots;

double LowestBuy = 1000, HighestBuy;

if (BarTime != Time[0])

{

BarTime = Time[0];

TickPrice = 0;

TradeAllowed = true;

}

RefreshRates();

for (Order = OrdersTotal() - 1; Order >= 0; Order--)

{

if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_BUY)

{

if (OrderOpenPrice() < LowestBuy) LowestBuy = OrderOpenPrice();

if (OrderOpenPrice() > HighestBuy) HighestBuy = OrderOpenPrice();

BuyOrders++;

}

}

}

if (TradeAllowed)

{

if (Ask >= HighestBuy + (TrendSpacing * Point))

{

// if (Multiplier)

if (Multiplier == 1)

Lots = NormalizeDouble(LotSize * MathPow(LotIncrement, BuyOrders), 2);

else

Lots = NormalizeDouble(LotSize + (LotIncrement * BuyOrders), 2);

}

if (Ask <= LowestBuy - (Spacing * Point))

{

// if (Multiplier)

if (Multiplier == 1)

Lots = NormalizeDouble(LotSize * CounterTrendMultiplier * MathPow(LotIncrement, BuyOrders), 2);

else

Lots = NormalizeDouble((LotSize * CounterTrendMultiplier) + (LotIncrement * BuyOrders), 2);

}

if (Lots == 0)

{

// if (Multiplier)

if (Multiplier == 1)

Lots = NormalizeDouble(LotSize, 2);

else

Lots = NormalizeDouble(LotSize, 2);

}

OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, TradeComment, Reference, Green);

Error = GetLastError();

if (Error != 0)

Write("Error opening BUY order: " + ErrorDescription(Error) + " (C" + Error + ") Ask:" + Ask + " Slippage:" + Slippage);

else

{

TickPrice = Close[0];

TradeAllowed = false;

}

}

}

void PlaceSellOrder()

{

double SellOrders, Lots;

double HighestSell, LowestSell = 1000;

if (BarTime != Time[0])

{

BarTime = Time[0];

TickPrice = 0;

TradeAllowed = true;

}

RefreshRates();

for (Order = OrdersTotal() - 1; Order >= 0; Order--)

{

if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_SELL)

{

if (OrderOpenPrice() > HighestSell) HighestSell = OrderOpenPrice();

if (OrderOpenPrice() < LowestSell) LowestSell = OrderOpenPrice();

SellOrders++;

}

}

}

if (TradeAllowed)

{

if (Bid <= LowestSell - (TrendSpacing * Point))

{

// if (Multiplier)

if (Multiplier == 1)

Lots = NormalizeDouble(LotSize * MathPow(LotIncrement, SellOrders), 2);

else

Lots = NormalizeDouble(LotSize + (LotIncrement * SellOrders), 2);

}

if (Bid >= HighestSell + (Spacing * Point))

{

// if (Multiplier)

if (Multiplier == 1)

Lots = NormalizeDouble(LotSize * CounterTrendMultiplier * MathPow(LotIncrement, SellOrders), 2);

else

Lots = NormalizeDouble((LotSize * CounterTrendMultiplier) + (LotIncrement * SellOrders), 2);

}

if (Lots == 0)

{

// if (Multiplier)

if (Multiplier == 1)

Lots = NormalizeDouble(LotSize, 2);

else

Lots = NormalizeDouble(LotSize, 2);

}

OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, TradeComment, Reference, Red);

Error = GetLastError();

if (Error != 0)

Write("Error opening SELL order: " + ErrorDescription(Error) + " (D" + Error + ") Bid:" + Bid + " Slippage:" + Slippage);

else

{

TickPrice = Close[0];

TradeAllowed = false;

}

}

}

Is this some that can be done?

 

HELP~just 1 error, use 3 Hours still can't find it out

I AM VERY WORRY , BECAUSE I CAN'T FIND how to correct the error below

can anyone tell me where is the mistake? or help me to debug , i have attached the files, see buttom~ ~

'\end_of_program' - unbalanced left parenthesis C:\Program Files\ MetaTrader\experts\scripts\delete_pending_SAM.mq4 (38, 2)

IT IS A SCRIPT FILE~ ~

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

//| delete_pending.mq4 |

//| Copyright ?2004, MetaQuotes Software Corp. |

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

#property copyright "Copyright ?2004, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net/"

#property show_inputs

bool result;

extern double OverSymbolDel = 1; //0:FASLE ; 1: TRUE

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

//| script "delete pending order" |

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

int start()

{

for (int number=0; (number <= OrdersTotal()+1); number++ )

{for (int times=0;( times <= OrdersTotal()+1); times++ )

{if (OrderSelect(number,SELECT_BY_POS,MODE_TRADES) )

{if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) break;

if ((OverSymbolDel ==0)&& (Symbol()==OrderSymbol() ) delPending();

if (OverSymbolDel ==1) delPending();

}

else Print("Error when Order Select ", GetLastError() ) ;

}

}

}

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

void delPending()

{OrderPrint();

int ticket =OrderTicket();

result=OrderDelete(ticket);

if (result==False) Print("Error when delete Order ", GetLastError() );

}

Files:
 

To chiwing

Try this:

#property copyright "Copyright ?2004, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net/"

#property show_inputs

bool result;

extern double OverSymbolDel = 1; //0:FASLE ; 1: TRUE

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

//| script "delete pending order" |

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

int start()

{

for (int number=OrdersTotal()-1; number >= 0; number--)

{

OrderSelect(number,SELECT_BY_POS,MODE_TRADES);

if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) continue;

if (OverSymbolDel ==0&& Symbol()==OrderSymbol() ) delPending();

if (OverSymbolDel ==1) delPending();

}

}

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

void delPending()

{

OrderPrint();

int ticket =OrderTicket();

result=OrderDelete(ticket);

if (!result) Print("Error when delete Order ", GetLastError() );

}
 
Roger09:
To chiwing

Try this:

#property copyright "Copyright ?2004, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net/"

#property show_inputs

bool result;

extern double OverSymbolDel = 1; //0:FASLE ; 1: TRUE

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

//| script "delete pending order" |

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

int start()

{

for (int number=OrdersTotal()-1; number >= 0; number--)

{

OrderSelect(number,SELECT_BY_POS,MODE_TRADES);

if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) continue;

if (OverSymbolDel ==0&& Symbol()==OrderSymbol() ) delPending();

if (OverSymbolDel ==1) delPending();

}

}

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

void delPending()

{

OrderPrint();

int ticket =OrderTicket();

result=OrderDelete(ticket);

if (!result) Print("Error when delete Order ", GetLastError() );

}

thanks for your help~ ~

and i find my mistake :

{if (OrderSelect(number,SELECT_BY_POS,MODE_TRADES) )

change to

OrderSelect(number,SELECT_BY_POS,MODE_TRADES);

{if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) break;

change to

if((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ) countinue;