السلام عليكم إخواني
قمت بإضافة الكود LastOpenPrice
الشراء فقط إذا كانت آخر صفقة أصغر من السعر الحالي
و البيع فقط إذا كانت آخر صفقة أكبر من السعر الحالي
لكن المشكلة هي أن الإكسبرت يشتري فقط ولا يبيع
كود:
//+------------------------------------------------------------------+ //| boujie.mq4 | //| Copyright 2015, Hamza Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Hamza Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict input string s1 = "--------------Trend--------------"; extern int TMperiod = 200; extern int TMshift = 0; extern int TMmethod = 0; extern int TMapplied = 0; input string s2 = "---------Money Management--------------"; input int TP = 30 ; input int SL = 15 ; input double lots = 0.1 ; input int Magic = 11111 ; double pclose = iClose(Symbol(),PERIOD_D1,1); double popo = iClose(Symbol(),0,1); double t ; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- double ticksize = MarketInfo (Symbol(),MODE_TICKSIZE); if ( ticksize == 0.00001 || 0.001 ) t = ticksize * 10; else t = ticksize ; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double Tnow = iMA(NULL,0,TMperiod,TMshift,TMmethod,TMapplied,1); //--- if(Close[1]>High[2] && Tnow < Ask && LastOpenPrice () < Ask ){ if(OrdersTotal()==0) bool Buy = OrderSend(NULL,OP_BUY,lots,Ask,30,Ask-(SL*t),Ask+(TP*t),NULL,Magic,0,Blue); } if(Close[1]<Low[2] && Tnow > Bid && LastOpenPrice () > Bid ){ if(OrdersTotal()==0) bool n=OrderSend(NULL,OP_SELL,lots,Bid,30,Bid+(SL*t),Bid-(TP*t),NULL,Magic,0,Red); } } //+------------------------------------------------------------------+ //////////////////////////////////////////////////////////////////////////////////////////////// double LastOpenPrice () { for (int i=OrdersTotal()-1;i>=0;i--){ bool lop=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic ){ return(OrderOpenPrice()); } } return(0); } ////////////////////////////////////////////////////////////////////////////////////////////////