Hello i would like to create an pyramide system together.I want to learn a lot from this project and get some respons if there are any misstakes made in the program.
The idea is to create a little bit of programming each time and see if we can and with a nice program. Hopefully you like this idea and come also with great ideas.
So let's start with setting the program for a 4 or 5 digits brooker.
Your start with setting the program for a 4 or 5 digits broker not very helpfull to others...
Well i am also waiting on respons of other people.I am just a beginner try to figure things out.
But let's make the program a little bit bigger
//+------------------------------------------------------------------+ //| mql4pyramide.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright #property link #property version "1.00" #property strict double pips; extern double maxprice = 25; extern double magicnumber = 100; double steplevel1 = MarketInfo(Symbol(),MODE_SPREAD); double static buy1; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize ==0.0001||ticksize ==0.001) pips = ticksize * 10; else pips = ticksize; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- openbuy1(); } //+------------------------------------------------------------------+ void openbuy1 () { double lot = 0.01; if (Close[0]<maxprice) OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"Buy",magicnumber,Green); buy1 = Close[0]-steplevel1*pips; }
I have two questions how to fix the next 2 problems?
Anyone a solution?
possible loss of data due to type conversion mql4pyramide 51 47
return value of 'OrderSend' should be checked mql4pyramide 51 1
Hello i would like to create an pyramide system together.I want to learn a lot from this project and get some respons if there are any misstakes made in the program.
The idea is to create a little bit of programming each time and see if we can and with a nice program. Hopefully you like this idea and come also with great ideas.
So let's start with setting the program for a 4 or 5 digits brooker.
My opinion is..., I see that you have wrong approach.
-: "Hello i would like to create an pyramide system together. " - A: Good, that the goal. ("pyramide" =? pyramid or pyramided..?)
-: "I want to learn a lot from this project and get some response if there are any mistakes made in the program." - A: Good, now you need structure of the program. (Assuming you have the hardware)
-: "The idea is to create a little bit of programming each time and see if we can and with a nice program. " A: OK, that's a practice for your skills.
-: "So let's start with setting the program for a 4 or 5 digits brooker." A: ...start =? from which structure? It does not have to be tree, but start structure could point to your vision-idea. (4 or 5 digits brooker is just adapting)
Thanks for reaction.
sorry for some writing misstake i mean pyramid.
The fisrt step of the program is to buy 0.01 lot of a stock(nokia) at certain level.
I take a stock like nokia because the highest lost if the company goes broke will be about 500 to 1000 euro the profit will be about 10% a year.If you have to invest 500 to 1000 euro.
but maybe you have solution for the next problems.
possible loss of data due to type conversion mql4pyramide 51 47
return value of 'OrderSend' should be checked mql4pyramide 51 1
Oke i have solved one problem.
//+------------------------------------------------------------------+ //| mql4pyramide.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright #property link #property version "1.00" #property strict double pips; extern double maxprice = 25; extern double magicnumber = 100; double steplevel1 = MarketInfo(Symbol(),MODE_SPREAD); double static buy1; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize ==0.0001||ticksize ==0.001) pips = ticksize * 10; else pips = ticksize; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- openbuy1(); } //+------------------------------------------------------------------+ void openbuy1 () { double lot = 0.01; if (Close[0]<maxprice) int buyorder =OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"Buy",magicnumber,Green); buy1 = Close[0]-steplevel1*pips; }
But still need to solve this warning. Any ideas???
possible loss of data due to type conversion mql4pyramid 51 61
int OrderSend( string symbol, // symbol int cmd, // operation double volume, // volume double price, // price int slippage, // slippage double stoploss, // stop loss double takeprofit, // take profit string comment=NULL, // comment int magic=0, // magic number datetime expiration=0, // pending order expiration color arrow_color=clrNONE // color );
extern double magicnumber = 100;
Why use static when declaring a variable globally? You don't when declaring pips.
double pips; double static buy1;
Oke thanks changing double magicnumber to int did the trick.
I use static because futher on i want it to be static.
//+------------------------------------------------------------------+ //| mql4pyramide.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright #property link #property version "1.00" #property strict double pips; extern double maxprice = 25; extern int magicnumber = 100; double steplevel1 = MarketInfo(Symbol(),MODE_SPREAD); double trailerpoints1 =MarketInfo(Symbol(),MODE_STOPLEVEL); double static buy1; double buyorder; double adjustorder; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize ==0.0001||ticksize ==0.001) pips = ticksize * 10; else pips = ticksize; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- AdjustTrail(); openbuy1(); } //+------------------------------------------------------------------+ void openbuy1 () { double lot = 0.01; if (Close[0]<maxprice) buyorder = OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"Buy",magicnumber,Green); buy1 = Close[0]-steplevel1*pips; } void AdjustTrail() { for(int b = OrdersTotal()-1;b >= 0;b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==magicnumber) if (OrderSymbol()==Symbol()) if(OrderType()==OP_BUY) if(Bid-OrderOpenPrice()>(steplevel1+trailerpoints1)*pips) if(OrderStopLoss()<Bid-pips*(trailerpoints1)) adjustorder = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(pips*(trailerpoints1)),OrderTakeProfit(),0,CLR_NONE); if( buy1<OrderTakeProfit()) buy1 = Close[0]-steplevel1*pips; }}
So what do we have now.
1 we can use it on diverent brookers
2 we open a order when the price is below maxprice
3 we save the next buylevel in buy1
4 we adjust trail when the buy is a profit
5 we save the buylevel to a new level in buy1
so far so good
So now we are going to ad a loop to count the buy orders.
//+------------------------------------------------------------------+ //| mql4pyramide.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright #property link #property version "1.00" #property strict double pips; extern double maxprice = 25; extern int magicnumber = 100; double steplevel1 = MarketInfo(Symbol(),MODE_SPREAD); double trailerpoints1 =MarketInfo(Symbol(),MODE_STOPLEVEL); double static buy1; double buyorder; double adjustorder; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize ==0.0001||ticksize ==0.001) pips = ticksize * 10; else pips = ticksize; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- AdjustTrail(); int BuyCnt = 0; int SellCnt = 0; int BuyStopCnt = 0; int SellStopCnt = 0; int BuyLimitCnt = 0; int SellLimitCnt = 0; int cnt = OrdersTotal(); for (int i=0; i < cnt; i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; if (OrderSymbol() != Symbol()) continue; if (OrderMagicNumber() != magicnumber) continue; int type = OrderType(); if (type == OP_BUY) BuyCnt++; if (type == OP_SELL) SellCnt++; if (type == OP_BUYSTOP) BuyStopCnt++; if (type == OP_SELLSTOP) SellStopCnt++; if (type == OP_BUYLIMIT) BuyLimitCnt++; if (type == OP_SELLLIMIT) SellLimitCnt++; if(BuyCnt==0)openbuy1(); } } //+------------------------------------------------------------------+ void openbuy1 () { double lot = 0.01; if (Close[0]<maxprice) buyorder = OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"Buy",magicnumber,Green); buy1 = Close[0]-steplevel1*pips; } void AdjustTrail() { for(int b = OrdersTotal()-1;b >= 0;b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==magicnumber) if (OrderSymbol()==Symbol()) if(OrderType()==OP_BUY) if(Bid-OrderOpenPrice()>(steplevel1+trailerpoints1)*pips) if(OrderStopLoss()<Bid-pips*(trailerpoints1)) adjustorder = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(pips*(trailerpoints1)),OrderTakeProfit(),0,CLR_NONE); if( buy1<OrderTakeProfit()) buy1 = Close[0]-steplevel1*pips; }}
//+------------------------------------------------------------------+ //| mql4pyramide.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright #property link #property version "1.00" #property strict double pips; extern double maxprice = 25; extern int magicnumber = 100; double steplevel1 = MarketInfo(Symbol(),MODE_SPREAD); double trailerpoints1 =MarketInfo(Symbol(),MODE_STOPLEVEL); double static buy1; double buyorder; double adjustorder; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize ==0.0001||ticksize ==0.001) pips = ticksize * 10; else pips = ticksize; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- AdjustTrail(); int BuyCnt = 0; int SellCnt = 0; int BuyStopCnt = 0; int SellStopCnt = 0; int BuyLimitCnt = 0; int SellLimitCnt = 0; int cnt = OrdersTotal(); for (int i=0; i < cnt; i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; if (OrderSymbol() != Symbol()) continue; if (OrderMagicNumber() != magicnumber) continue; int type = OrderType(); if (type == OP_BUY) BuyCnt++; if (type == OP_SELL) SellCnt++; if (type == OP_BUYSTOP) BuyStopCnt++; if (type == OP_SELLSTOP) SellStopCnt++; if (type == OP_BUYLIMIT) BuyLimitCnt++; if (type == OP_SELLLIMIT) SellLimitCnt++; } if(BuyCnt==0)openbuy1(); } //+------------------------------------------------------------------+ void openbuy1 () { double lot = 0.01; if (Close[0]<maxprice) buyorder = OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"Buy",magicnumber,Green); buy1 = Close[0]-steplevel1*pips; } void AdjustTrail() { for(int b = OrdersTotal()-1;b >= 0;b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==magicnumber) if (OrderSymbol()==Symbol()) if(OrderType()==OP_BUY) if(Bid-OrderOpenPrice()>(steplevel1+trailerpoints1)*pips) if(OrderStopLoss()<Bid-pips*(trailerpoints1)) adjustorder = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(pips*(trailerpoints1)),OrderTakeProfit(),0,CLR_NONE); if( buy1<OrderTakeProfit()) buy1 = Close[0]-steplevel1*pips; }}
Hello again
I like to set the buy1 value as Global so if i turn the computer on again it knows the values i had.
I would like to know if i am doing this right with the GlobalVariabelSet check the code please.
And i have the next warning
declaration of 'nokia1' hides global declaration at line 23
How can i solve this problem.
//+------------------------------------------------------------------+ //| mql4pyramid.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright #property link #property version "1.00" #property strict double pips; extern double maxprice = 25; extern int magicnumber = 100; double steplevel1 = MarketInfo(Symbol(),MODE_SPREAD); double trailerpoints1 =MarketInfo(Symbol(),MODE_STOPLEVEL); double buyorder; double adjustorder; double static buy1; string nokia1 ="newvaluenokia1"; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE); if(ticksize ==0.0001||ticksize ==0.001) pips = ticksize * 10; else pips = ticksize; double nokia1 = GlobalVariableGet(nokia1); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- AdjustTrail(); int BuyCnt = 0; int SellCnt = 0; int BuyStopCnt = 0; int SellStopCnt = 0; int BuyLimitCnt = 0; int SellLimitCnt = 0; int cnt = OrdersTotal(); for (int i=0; i < cnt; i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; if (OrderSymbol() != Symbol()) continue; if (OrderMagicNumber() != magicnumber) continue; int type = OrderType(); if (type == OP_BUY) BuyCnt++; if (type == OP_SELL) SellCnt++; if (type == OP_BUYSTOP) BuyStopCnt++; if (type == OP_SELLSTOP) SellStopCnt++; if (type == OP_BUYLIMIT) BuyLimitCnt++; if (type == OP_SELLLIMIT) SellLimitCnt++; } if(BuyCnt==0)openbuy1(); } //+------------------------------------------------------------------+ void openbuy1 () { double lot = 0.01; if (Close[0]<maxprice) buyorder = OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"Buy",magicnumber,Green); buy1 = Close[0]-steplevel1*pips; GlobalVariableSet(nokia1,buy1); } void AdjustTrail() { for(int b = OrdersTotal()-1;b >= 0;b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==magicnumber) if (OrderSymbol()==Symbol()) if(OrderType()==OP_BUY) if(Bid-OrderOpenPrice()>(steplevel1+trailerpoints1)*pips) if(OrderStopLoss()<Bid-pips*(trailerpoints1)) adjustorder = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(pips*(trailerpoints1)),OrderTakeProfit(),0,CLR_NONE); if( buy1<OrderTakeProfit()) buy1 = Close[0]-steplevel1*pips; }}

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello i would like to create an pyramide system together.I want to learn a lot from this project and get some respons if there are any misstakes made in the program.
The idea is to create a little bit of programming each time and see if we can and with a nice program. Hopefully you like this idea and come also with great ideas.
So let's start with setting the program for a 4 or 5 digits brooker.